1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-17 23:05:03 -05:00

Fix for Brazilian Portuguese language preferences when using OpenSubtitles

@see https://www.filebot.net/forums/viewtopic.php?f=8&t=4992
This commit is contained in:
Reinhard Pointner 2017-04-22 21:55:27 +08:00
parent 91b0074e70
commit aff5407a1a

View File

@ -465,6 +465,17 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS
return subLanguageMap; return subLanguageMap;
} }
protected String getLanguageCode(Locale locale) {
switch (locale.toString()) {
case "pt_BR":
return "pb";
case "zh_TW":
return "tw";
default:
return locale.getLanguage();
}
}
protected String[] getLanguageFilter(Locale locale) { protected String[] getLanguageFilter(Locale locale) {
return locale == null || locale.getLanguage().isEmpty() ? new String[0] : new String[] { getSubLanguageID(locale) }; return locale == null || locale.getLanguage().isEmpty() ? new String[0] : new String[] { getSubLanguageID(locale) };
} }
@ -476,7 +487,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS
String subLanguageID = null; String subLanguageID = null;
try { try {
subLanguageID = getSubLanguageMap().get(locale.getLanguage()); subLanguageID = getSubLanguageMap().get(getLanguageCode(locale));
} catch (Exception e) { } catch (Exception e) {
throw new IllegalStateException("Failed to retrieve subtitle language map", e); throw new IllegalStateException("Failed to retrieve subtitle language map", e);
} }