@Immutable public final class LocaleUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static EChange |
clearCache()
Clear all stored locale lists
|
static Map<Locale,String> |
getAllLocaleDisplayNames(Locale aContentLocale)
Get all possible locale names in the passed locale
|
static List<Locale> |
getCalculatedLocaleListForResolving(Locale aLocale)
Get a list with all valid locale permutations of the passed locale.
|
static String |
getLocaleDisplayName(Locale aLocale,
Locale aContentLocale)
Get the display name of the passed language in the currently selected UI
language.
|
static Locale |
getLocaleFromString(String sLocaleAsString)
Convert a String in the form "language-country-variant" to a Locale object.
|
static String |
getLocaleNativeDisplayName(Locale aLocale)
Get the display name of the passed locale in the passed locale.
|
static Locale |
getLocaleToUseOrFallback(Locale aRequestLocale,
Collection<Locale> aAvailableLocales,
Locale aFallback) |
static Locale |
getLocaleToUseOrNull(Locale aRequestLocale,
Collection<Locale> aAvailableLocales) |
static String |
getValidCountryCode(String sCode) |
static String |
getValidLanguageCode(String sCode) |
static boolean |
isSpecialLocale(Locale aLocale)
Check if the passed locale is one of the special locales "all" or
"independent"
|
static boolean |
isSpecialLocaleCode(String sLocale)
Check if the passed locale is one of the special locales "all" or
"independent"
|
@Nonnull public static String getLocaleDisplayName(@Nullable Locale aLocale, @Nonnull Locale aContentLocale)
aLocale - The locale from which the display name is required. May be
null.aContentLocale - The locale in which the name of the locale is required. If aLocale
is "de" and display locale is "de" the result would be "Deutsch"
whereas if display locale is "en" the result would be "German".null, "all" or "independent"CGlobal.LOCALE_ALL,
CGlobal.LOCALE_INDEPENDENT@Nonnull public static String getLocaleNativeDisplayName(@Nonnull Locale aLocale)
aLocale - The locale to use. May not be null.@Nonnull @ReturnsMutableCopy public static Map<Locale,String> getAllLocaleDisplayNames(@Nonnull Locale aContentLocale)
aContentLocale - the locale ID in which the language list is required@Nonnull @ReturnsImmutableObject public static List<Locale> getCalculatedLocaleListForResolving(@Nonnull Locale aLocale)
aLocale - The locale to get the permutation from. May not be null
.null unmodifiable list of all permutations of
the locale, with the most specific locale being first. The returned
list has never more than three entries. The returned list may have
no entries, if the passed locale has no language.@Nonnull public static Locale getLocaleFromString(@Nullable String sLocaleAsString)
sLocaleAsString - The string representation to be converted to a Locale.null. If the passed parameter is
null or empty, SystemHelper.getSystemLocale()
is returned.@Nullable public static Locale getLocaleToUseOrNull(@Nonnull Locale aRequestLocale, @Nonnull Collection<Locale> aAvailableLocales)
@Nullable public static Locale getLocaleToUseOrFallback(@Nonnull Locale aRequestLocale, @Nonnull Collection<Locale> aAvailableLocales, @Nullable Locale aFallback)
public static boolean isSpecialLocale(@Nullable Locale aLocale)
aLocale - The locale to check. May be null.null and a special locale.CGlobal.LOCALE_ALL,
CGlobal.LOCALE_INDEPENDENTpublic static boolean isSpecialLocaleCode(@Nullable String sLocale)
sLocale - The locale to check. May be null.null and a special locale.CGlobal.LOCALE_ALL,
CGlobal.LOCALE_INDEPENDENTCopyright © 2006–2015 phloc systems. All rights reserved.