List of usage examples for org.apache.commons.lang LocaleUtils localeLookupList
public static List localeLookupList(Locale locale)
Obtains the list of locales to search through when performing a locale search.
localeLookupList(Locale("fr","CA","xxx")) = [Locale("fr","CA","xxx"), Locale("fr","CA"), Locale("fr")]
From source file:fr.gouv.culture.thesaurus.util.LangUtils.java
@SuppressWarnings("unchecked") public static List<Locale> expand(Locale[] locales) { List<Locale> expandedLocales = new LinkedList<Locale>(); for (Locale locale : locales) { if (locale != null) { expandedLocales.addAll(LocaleUtils.localeLookupList(locale)); } else {// w w w. ja v a 2s. c om expandedLocales.add(null); } } return expandedLocales; }
From source file:fr.gouv.culture.thesaurus.service.rdf.RdfResource.java
/** * Returns an entry property value in the specified locale, if possible. If * there is no value in the specified locale, considers the neutral * language.//from ww w . j a va 2 s. co m * * @param property * the property URI. * @param locale * the language tagging the property value or <code>null</code> * to get the value without any language tag. * @return the first value of the property tagged with the specified * language or <code>null</code> if none is present. */ public LocalizedString getPreferredProperty(String property, Locale preferredLocale) { @SuppressWarnings("unchecked") List<Locale> locales = LocaleUtils.localeLookupList(preferredLocale); for (Locale locale : locales) { String localeStr = LangUtils.localeString(locale); LocalizedString value = this.getProperty(property, localeStr); if (value != null) { return value; } } if (preferredLocale != null) { return this.getProperty(property, null); } return null; }
From source file:net.geoprism.localization.LocaleManager.java
@SuppressWarnings("unchecked") private static Locale getBestFitLocale(Locale _locale, Collection<Locale> _locales) { List<Locale> lookups = (List<Locale>) LocaleUtils.localeLookupList(_locale); for (Locale lookup : lookups) { if (_locales.contains(lookup)) { return lookup; }//w w w .j a va 2 s.co m } // There is no best fit, return English as the default locale return Locale.ENGLISH; }
From source file:org.xdi.oxauth.model.util.LocaleUtil.java
public static Locale localeMatch(List<String> requestedLocales, List<Locale> availableLocales) { if (requestedLocales == null || availableLocales == null) { return null; }//from ww w .j a v a 2 s .c o m for (String requestedLocale : requestedLocales) { Locale reqInQuestion = LocaleUtils.toLocale(requestedLocale); List<Locale> lookupList = LocaleUtils.localeLookupList(reqInQuestion); for (Locale localeInQuestion : lookupList) { for (Locale availableLocale : availableLocales) { if (localeInQuestion.equals(availableLocale)) { return availableLocale; } } } for (Locale availableLocale : availableLocales) { if (reqInQuestion.getLanguage().equals(availableLocale.getLanguage())) { return availableLocale; } } } return null; }