|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.extensions.surf.util.I18NUtil
public class I18NUtil
Utility class providing methods to access the Locale of the current thread and to get Localised strings.
| Constructor Summary | |
|---|---|
I18NUtil()
|
|
| Method Summary | |
|---|---|
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 |
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 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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public I18NUtil()
| Method Detail |
|---|
public static void setLocale(Locale locale)
locale - the localepublic static Locale getLocale()
public static void setContentLocale(Locale locale)
locale - the content localepublic static Locale getContentLocale()
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 from
public static Locale parseLocale(String localeStr)
localeStr - e.g. fr_FR
default 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 key
public static String getMessage(String messageKey,
Locale locale)
messageKey - the message keylocale - override the current locale
public static String getMessage(String messageKey,
Object... params)
messageKey - message keyparams - format parameters
public static String getMessage(String messageKey,
Locale locale,
Object... params)
messageKey - the message keylocale - override current localeparams - the localised message string
public static Map<String,String> getAllMessages()
public static Map<String,String> getAllMessages(Locale locale)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||