public class LanguageCodeConverters extends Object
Title: Utility class to convert between the different type of language codes encodings.
Description: This class was design to offer conversion tools between various language code encodings into Strings, Locales and other types of objects.
Copyright: Copyright (c) 2002
Company:
| Modifier and Type | Class and Description |
|---|---|
static class |
LanguageCodeConverters.LocaleDisplayNameComparator
Comparator implementation that compares locale display names in a certain
current locale.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
JAVA7_LOCALE_TOSTRING |
static Pattern |
LANGUAGE_PATTERN |
| Constructor and Description |
|---|
LanguageCodeConverters() |
| Modifier and Type | Method and Description |
|---|---|
static List<Locale> |
getAvailableBundleLocales() |
static List<Locale> |
getAvailableBundleLocales(String resourceBundleName,
Locale defaultLocale) |
static List<Locale> |
getAvailableBundleLocalesSorted() |
static List<Locale> |
getAvailableBundleLocalesSorted(Locale currentLocale) |
static LanguageCodeConverters.LocaleDisplayNameComparator |
getLocaleDisplayNameComparator(Locale locale) |
static Locale |
getLocaleFromCode(String code)
Converts (alt) string such as
en_US, fr_CH_unix, fr, en, _GB, fr__UNIX
into Locale objects.
|
static List<Locale> |
getSortedLocaleList(Locale currentLocale) |
static boolean |
isValidLanguageCode(String languageCode)
Tests if the language code is valid or not, according to the Locale.toString() format.
|
static Locale |
languageCodeToLocale(String languageCode)
Converts string such as
en_US, fr_CH_unix, fr, en, _GB, fr__UNIX
into Locale objects.
|
static Locale |
languageTagsToLocale(String languageCode)
Converts language tags encoded (RFC 3066) to Locales.
|
static List<String> |
localesToLanguageCodes(List<Locale> locales) |
static String |
localeToLanguageTag(Locale locale)
Returns a language tags encoded (RFC 3066) compliant string from
a Java Locale object.
|
static Locale |
resolveLocaleForGuest(javax.servlet.http.HttpServletRequest request) |
public static final Pattern LANGUAGE_PATTERN
public static final String JAVA7_LOCALE_TOSTRING
public static boolean isValidLanguageCode(String languageCode)
languageCode - public static Locale languageCodeToLocale(String languageCode)
languageCode - the encoded stringpublic static Locale getLocaleFromCode(String code)
code - the encoded stringpublic static Locale languageTagsToLocale(String languageCode)
languageCode - the encoded stringpublic static String localeToLanguageTag(Locale locale)
locale - the locale we want to be converted.public static Locale resolveLocaleForGuest(javax.servlet.http.HttpServletRequest request)
public static LanguageCodeConverters.LocaleDisplayNameComparator getLocaleDisplayNameComparator(Locale locale)
public static List<Locale> getAvailableBundleLocales(String resourceBundleName, Locale defaultLocale)
public static List<Locale> getAvailableBundleLocalesSorted(Locale currentLocale)
Copyright © 2004–2020 Jahia Solutions Group SA. All rights reserved.