* some hacks to make pb/pob "Brazilian Portuguese" work as expected even though it's not officially a language according to the ISO standards

This commit is contained in:
Reinhard Pointner 2013-12-14 02:22:31 +00:00
parent cd21b195a7
commit 14c5821afb
3 changed files with 15 additions and 6 deletions

View File

@ -426,7 +426,7 @@ public class MediaBindingBean {
Locale languageSuffix = releaseInfo.getLanguageSuffix(FileUtilities.getName(mediaFile));
if (languageSuffix != null)
return new Locale(languageSuffix.getISO3Language()); // force ISO3 letter-code
return languageSuffix;
// require subtitle file
if (!SUBTITLE_FILES.accept(mediaFile)) {

View File

@ -449,21 +449,28 @@ public class ReleaseInfo {
@SuppressWarnings("unchecked")
Comparator<String> order = (Comparator) collator;
Map<String, Locale> languageMap = languageMap = new TreeMap<String, Locale>(order);
Map<String, Locale> languageMap = new TreeMap<String, Locale>(order);
for (String code : Locale.getISOLanguages()) {
Locale locale = new Locale(code);
languageMap.put(locale.getLanguage(), locale);
languageMap.put(locale.getISO3Language(), locale);
Locale locale = new Locale(code); // force ISO3 language as default toString() value
Locale iso3locale = new Locale(locale.getISO3Language());
languageMap.put(locale.getLanguage(), iso3locale);
languageMap.put(locale.getISO3Language(), iso3locale);
// map display language names for given locales
for (Locale language : new HashSet<Locale>(asList(supportedDisplayLocale))) {
// make sure language name is properly normalized so accents and whatever don't break the regex pattern syntax
String languageName = Normalizer.normalize(locale.getDisplayLanguage(language), Form.NFKD);
languageMap.put(languageName.toLowerCase(), locale);
languageMap.put(languageName.toLowerCase(), iso3locale);
}
}
// unofficial language for pb/pob for Portuguese (Brazil)
Locale brazil = new Locale("pob");
languageMap.put("pb", brazil);
languageMap.put("pob", brazil);
// remove illegal tokens
languageMap.remove("");
languageMap.remove("II");

View File

@ -447,10 +447,12 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS
for (Entry<String, String> entry : xmlrpc.getSubLanguages().entrySet()) {
// map id by name
subLanguageMap.put(entry.getValue().toLowerCase(), entry.getKey().toLowerCase());
subLanguageMap.put(entry.getKey().toLowerCase(), entry.getKey().toLowerCase()); // add reverse mapping as well for improved compatibility
}
// some additional special handling
subLanguageMap.put("brazilian", "pob");
subLanguageMap.put("pob", "pob");
// cache data
cache.put(cacheKey, subLanguageMap);