/** * tries to get local (JVM language) COUNTRY name for given parameters/variants * * @param countries * all possible names or iso codes * @return localized country name, or first country param 1:1 if we cannot translate */ public static String getLocalizedCountry(String... countries) { return getLocalizedCountryForLanguage(Locale.getDefault().getLanguage(), countries); }
switch (style) { case ISO2: return LanguageUtils.getIso2LanguageFromLocalizedString(language); return LanguageUtils.getIso3LanguageFromLocalizedString(language); return LanguageUtils.getIso3BLanguageFromLocalizedString(language); return LanguageUtils.getEnglishLanguageNameFromLocalizedString(language); return LanguageUtils.getLocalizedLanguageNameFromLocalizedString(language);
/** * Get the ISO 639-2/B 3 letter code * * @param language * the 2 letter ISO code to get the 3 letter code for * @return the 3 letter code * @since 2.0 */ public static String getISO3BLanguage(String language) { return getISO3BLanguage(Locale.forLanguageTag(language)); }
if (ImdbMetadataProvider.providerInfo.getConfig().getValueAsBool("scrapeLanguageNames")) { md.addCountry( LanguageUtils.getLocalizedCountryForLanguage(options.getLanguage().getLanguage(), countryElement.text(), matcher.group(1))); if (ImdbMetadataProvider.providerInfo.getConfig().getValueAsBool("scrapeLanguageNames")) { md.addSpokenLanguage( LanguageUtils.getLocalizedLanguageNameFromLocalizedString(options.getLanguage(), languageElement.text(), matcher.group(1)));
/** * uses our localized language mapping table, to get the localized language name * * @param text * the language (as string) to get the language name for * @return the localized language name or the untranslated string 1:1 * @since 2.0 */ public static String getLocalizedLanguageNameFromLocalizedString(String text) { return getLocalizedLanguageNameFromLocalizedString(Locale.getDefault(), text); }
private String parseLanguageFromString(String shortname) { if (StringUtils.isBlank(shortname)) { return ""; } Set<String> langArray = LanguageUtils.KEY_TO_LOCALE_MAP.keySet(); shortname = shortname.replaceAll("(?i)Part [Ii]+", ""); // hardcoded; remove Part II which is no stacking marker; b/c II is a valid iso code :p shortname = StringUtils.split(shortname, '/')[0].trim(); // possibly "de / de" - just take first for (String s : langArray) { try { if (shortname.equalsIgnoreCase(s) || shortname.matches("(?i).*[ _.-]+" + Pattern.quote(s) + "$")) {// ends with lang + delimiter prefix LOGGER.debug("found language '" + s + "' in '" + this.getFilename()); return LanguageUtils.getIso3LanguageFromLocalizedString(s); } } catch (Exception e) { LOGGER.warn("Error parsing subtitle language from locale keyset: " + s, e); } } return ""; }
for (String langu : mp.language.split("\\|")) { langu = langu.trim(); String languIso = LanguageUtils.getIso2LanguageFromLocalizedString(langu); if (StringUtils.isNotBlank(languIso)) { languages.add(languIso);
md.addSpokenLanguage(LanguageUtils.getLocalizedLanguageNameFromLocalizedString(options.getLanguage(), lang.name, lang.iso_639_1)); md.addCountry(LanguageUtils.getLocalizedCountryForLanguage(options.getLanguage(), country.name, country.iso_3166_1));
sub.setLanguage(LanguageUtils.getIso3LanguageFromLocalizedString(lang)); break;
/** * tries to get localized COUNTRY name (in given language) for given parameters/variants * * @param countries * all possible names or iso codes * @return localized country name, or first country param 1:1 if we cannot translate */ public static String getLocalizedCountryForLanguage(String language, String... countries) { // KEY_TO_LOCALE_MAP is correct here, we want to get the language locale!!! return getLocalizedCountryForLanguage(KEY_TO_LOCALE_MAP.get(language.toLowerCase(Locale.ROOT)), countries); }
/** * uses our localized language mapping table, to get the iso3B code * * @param text * the language (as string) to get the iso3B code for * @return 3 chars or empty string * @since 2.0 */ public static String getIso3BLanguageFromLocalizedString(String text) { Locale l = KEY_TO_LOCALE_MAP.get(text.toLowerCase(Locale.ROOT)); if (l != null) { return getISO3BLanguage(l); } return ""; }
md.addCountry(LanguageUtils.getLocalizedCountryForLanguage(options.getLanguage(), country));
/** * opensubtitles need sometimes not ISO 639.2B - this method maps the exceptions * * @param locale * the language top be converted * @return the string accepted by opensubtitles */ private String getLanguageCode(Locale locale) { // default ISO 639.2B String languageCode = LanguageUtils.getISO3BLanguage(locale.getLanguage()); // and now the exceptions // greek: gre -> ell if ("gre".equals(languageCode)) { languageCode = "ell"; } return languageCode; }
langArray.put(LanguageUtils.getISO3BLanguage(base), base);