@Immutable public final class LocaleHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
static Locale |
LOCALE_ALL
the default locale which means "all locales".
|
static Locale |
LOCALE_INDEPENDENT
the default locale which means "locale independent".
|
static char |
LOCALE_SEPARATOR
Separates language and country in a locale string representation.
|
static String |
STR_ALL
The language string representing the "all" locale.
|
static String |
STR_INDEPENDENT
The language string representing the "independent" locale.
|
| Modifier and Type | Method and Description |
|---|---|
static EChange |
clearCache()
Clear all stored locale lists
|
static ICommonsMap<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"
|
public static final char LOCALE_SEPARATOR
public static final String STR_ALL
LOCALE_ALL.public static final Locale LOCALE_ALL
public static final String STR_INDEPENDENT
LOCALE_INDEPENDENT.public static final Locale LOCALE_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"LOCALE_ALL,
LOCALE_INDEPENDENT@Nonnull public static String getLocaleNativeDisplayName(@Nonnull Locale aLocale)
aLocale - The locale to use. May not be null.@Nonnull @ReturnsMutableCopy public static ICommonsMap<Locale,String> getAllLocaleDisplayNames(@Nonnull Locale aContentLocale)
aContentLocale - the locale ID in which the language list is required@Nonnull @ReturnsImmutableObject @CodingStyleguideUnaware 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.LOCALE_ALL,
LOCALE_INDEPENDENTpublic static boolean isSpecialLocaleCode(@Nullable String sLocale)
sLocale - The locale to check. May be null.null and a special locale.LOCALE_ALL,
LOCALE_INDEPENDENTCopyright © 2014–2017 Philip Helger. All rights reserved.