public class I18nUtil extends I18nConstants
LANGUAGE_PROPERTIES_FILENAME_REGEX, PROPERTIES_ONLY_NO_FALLBACK_CONTROL
Constructor and Description |
---|
I18nUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getJcmsTranslatedLanguageKey(java.util.Locale locale)
Retrieve the key of a language in which JCMS is translated, for the specified Locale.
|
static java.lang.String |
getLanguageKey(java.util.Locale locale)
Retrieve the language key to use as valid parameter of JCMS I18Ned API.
|
static java.util.Locale |
getLocale(java.lang.String languageKey)
Builds a new Locale from a language code, preserving any script
indication that may be part of the language parameter.
|
static java.util.Locale |
getLocale(java.lang.String languageKey,
java.lang.String country)
Builds a new Locale from a language and country code preserving any
script indication that may be part of the language parameter.
|
static java.lang.String |
getValidLanguageKey(java.lang.String languageKey)
Retrieve the language key to use as valid parameter of JCMS I18Ned API.
|
public static java.util.Locale getLocale(java.lang.String languageKey)
Script is only preserved when running on Java 1.7 (thus, you must run with Java 1.7 for advanced language support).
languageKey
- an ISO-639 language code (eg fr
), with an optionnal
script indication (eg zh-Hant
)java.lang.IllegalArgumentException
- if languageKey is nullgetLanguageKey(Locale)
public static java.util.Locale getLocale(java.lang.String languageKey, java.lang.String country)
Script is only preserved when running on Java 1.7 (thus, you must run with Java 1.7 for advanced language support).
languageKey
- an ISO-639 language code (eg fr
), with an optionnal script indication (eg zh-Hant
)country
- An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code. See the Locale class description about valid country valuesjava.lang.IllegalArgumentException
- if languageKey or country is nullgetLanguageKey(Locale)
public static java.lang.String getLanguageKey(java.util.Locale locale)
Given ANY Locale, this method will find the most appropriate language in which JCMS
currently configured, then return the corresponding language key.
If no suitable language could be found for the specified Locale (or if specified
Locale is null) it will default to the main site language.
This method behavior depends on the current site configuration, as only language configured on the site will be returned.
locale
- any LocaleJcmsUtil.glp(String, String, Object...)
methods as well as all
access to translated data values. never return null.public static java.lang.String getJcmsTranslatedLanguageKey(java.util.Locale locale)
Given ANY Locale, this method will find the most appropriate language in which JCMS
is translated, then return the corresponding language key used by JCMS.
If no suitable language could be found for the specified Locale, null is returned.
This method behavior does not depends on the current site configuration.
locale
- any Localepublic static java.lang.String getValidLanguageKey(java.lang.String languageKey)
Given ANY language (and its optionnal script variation), this method will find the most
appropriate language in which JCMS is currently configured, then return the corresponding language key.
If no suitable language could be found for the specified language (or if specified
language is null) it will default to the main site language.
This method behavior depends on the current site configuration, as only language configured on the site will be returned.
languageKey
- a string identifying a language and its optionnal script variation, eg ISO-639 ("en", "fr", "zh") or BCP 47 ("zh-Hant")JcmsUtil.glp(String, String, Object...)
methods as well as all
access to translated data values. never return null.Copyright © 2001-2010 Jalios SA. All Rights Reserved.