public class I18NUtil extends Object
| Constructor and Description |
|---|
I18NUtil() |
| Modifier and Type | Method and Description |
|---|---|
static Map<String,String> |
getAllMessages() |
static Map<String,String> |
getAllMessages(Locale locale) |
static Locale |
getContentLocale()
Get the content local for the current thread.
This will revert to getLocale() if no value has been defined. |
static Locale |
getContentLocaleLang()
Get the content local language only (ignore the country and variant) for the current thread.
This will revert to getLocale() if no value has been defined. |
static Locale |
getContentLocaleOrNull()
Get the content local for the current thread.
This will revert null if no value has been defined. |
static Locale |
getLocale()
Get the general local for the current thread, will revert to the default locale if none
specified for this thread.
|
static Locale |
getLocaleOrNull()
Get the general local for the current thread.
This will revert null if no value has been defined. |
static String |
getMessage(String messageKey)
Get message from registered resource bundle.
|
static String |
getMessage(String messageKey,
Locale locale)
Get a localised message string
|
static String |
getMessage(String messageKey,
Locale locale,
Object... params)
Get a localised message string, parameterized using standard MessageFormatter.
|
static String |
getMessage(String messageKey,
Object... params)
Get a localised message string, parameterized using standard MessageFormatter.
|
static Locale |
getNearestLocale(Locale templateLocale,
Set<Locale> options)
Searches for the nearest locale from the available options.
|
static Locale |
parseLocale(String localeStr)
Factory method to create a Locale from a lang_country_variant string.
|
static void |
registerResourceBundle(String bundleBaseName)
Register a resource bundle.
|
static void |
setContentLocale(Locale locale)
Set the content locale for the current thread.
|
static void |
setLocale(Locale locale)
Set the locale for the current thread.
|
public static void setLocale(Locale locale)
locale - the localepublic static Locale getLocale()
public static Locale getLocaleOrNull()
public static void setContentLocale(Locale locale)
locale - the content localepublic static Locale getContentLocale()
getLocale() if no value has been defined.public static Locale getContentLocaleLang()
getLocale() if no value has been defined.public static Locale getContentLocaleOrNull()
public static Locale getNearestLocale(Locale templateLocale, Set<Locale> options)
templateLocale - the template to search for or null to match any localeoptions - the available locales to search frompublic static Locale parseLocale(String localeStr)
localeStr - e.g. fr_FRdefault if the
string is invalidpublic static void registerResourceBundle(String bundleBaseName)
This should be the bundle base name eg, spring-surf.messages.errors
Once registered the messges will be available via getMessage
bundleBaseName - the bundle base namepublic static String getMessage(String messageKey)
messageKey - message keypublic static String getMessage(String messageKey, Locale locale)
messageKey - the message keylocale - override the current localepublic static String getMessage(String messageKey, Object... params)
messageKey - message keyparams - format parameterspublic static String getMessage(String messageKey, Locale locale, Object... params)
messageKey - the message keylocale - override current localeparams - the localised message stringpublic static Map<String,String> getAllMessages()
Copyright © 2017 Alfresco Software. All rights reserved.