private String getClosestW20Locale(String locale) { if (supportedLocales.contains(locale)) { return locale; } else { return localeMatcher.getBestMatch(ULocale.forLanguageTag(locale)).toLanguageTag(); } }
/** * @internal * @deprecated This API is ICU internal only. */ @Deprecated public ULocale getBestMatch(ULocale... ulocales) { return getBestMatch(LocalePriorityList.add(ulocales).build()); }
/** * Convenience method: Get the best match for a LanguagePriorityList * * @param languageList String form of language priority list * @return best matching language code * @stable ICU 4.4 */ public ULocale getBestMatch(String languageList) { return getBestMatch(LocalePriorityList.add(languageList).build()); }
ULocale getClosestULocale(String locale) { String defaultLocale = getDefaultLocale(); if (isAvailable(locale)) { return new ULocale(locale); } LocalePriorityList.Builder builder = null; if (defaultLocale != null) { builder = LocalePriorityList.add(defaultLocale); } for (String availableLocale : getAvailableLocales()) { if (defaultLocale == null || !defaultLocale.equals(availableLocale)) { if (builder == null) { builder = LocalePriorityList.add(availableLocale); } builder.add(availableLocale); } } if (builder != null) { LocaleMatcher localeMatcher = new LocaleMatcher(builder.build()); return localeMatcher.getBestMatch(locale); } else { return null; } } }
private ULocale getClosestULocale(String locale) { if (isAvailable(locale)) { return new ULocale(locale); } String defaultLocale = getDefaultLocale(); LocalePriorityList.Builder builder = null; if (defaultLocale != null) { builder = LocalePriorityList.add(defaultLocale); } for (String availableLocale : getAvailableLocales()) { if (defaultLocale == null || !defaultLocale.equals(availableLocale)) { if (builder == null) { builder = LocalePriorityList.add(availableLocale); } builder.add(availableLocale); } } if (builder != null) { LocaleMatcher localeMatcher = new LocaleMatcher(builder.build()); return localeMatcher.getBestMatch(locale); } else { return null; } } }