public class LocalizedTextUtil extends Object
Constructor and Description |
---|
LocalizedTextUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
addDefaultResourceBundle(String resourceBundleName)
Add's the bundle to the internal list of default bundles.
|
static void |
clearBundle(String bundleName)
Removes the bundle from any cached "misses"
|
static void |
clearDefaultResourceBundles()
Clears the internal list of resource bundles.
|
static String |
findDefaultText(String aTextName,
Locale locale)
Returns a localized message for the specified key, aTextName.
|
static String |
findDefaultText(String aTextName,
Locale locale,
Object[] params)
Returns a localized message for the specified key, aTextName, substituting variables from the
array of params into the message.
|
static ResourceBundle |
findResourceBundle(String aBundleName,
Locale locale)
Finds the given resorce bundle by it's name.
|
static String |
findText(Class aClass,
String aTextName,
Locale locale)
Calls
findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args)
with aTextName as the default message. |
static String |
findText(Class aClass,
String aTextName,
Locale locale,
String defaultMessage,
Object[] args)
Finds a localized text message for the given key, aTextName.
|
static String |
findText(Class aClass,
String aTextName,
Locale locale,
String defaultMessage,
Object[] args,
ValueStack valueStack)
Finds a localized text message for the given key, aTextName.
|
static String |
findText(ResourceBundle bundle,
String aTextName,
Locale locale)
Finds a localized text message for the given key, aTextName, in the specified resource bundle
with aTextName as the default message.
|
static String |
findText(ResourceBundle bundle,
String aTextName,
Locale locale,
String defaultMessage,
Object[] args)
Finds a localized text message for the given key, aTextName, in the specified resource
bundle.
|
static String |
findText(ResourceBundle bundle,
String aTextName,
Locale locale,
String defaultMessage,
Object[] args,
ValueStack valueStack)
Finds a localized text message for the given key, aTextName, in the specified resource
bundle.
|
static Locale |
localeFromString(String localeStr,
Locale defaultLocale)
Builds a
Locale from a String of the form en_US_foo into a Locale
with language "en", country "US" and variant "foo". |
static void |
reset()
Clears all the internal lists.
|
static void |
setDelegatedClassLoader(ClassLoader classLoader)
Sets a
ClassLoader to look up the bundle from if none can be found on the current thread's classloader |
static void |
setDevMode(boolean devMode) |
static void |
setReloadBundles(boolean reloadBundles)
Should resorce bundles be reloaded.
|
public static void clearDefaultResourceBundles()
public static void setReloadBundles(boolean reloadBundles)
reloadBundles
- reload bundles?public static void setDevMode(boolean devMode)
public static void addDefaultResourceBundle(String resourceBundleName)
resourceBundleName
- the name of the bundle to add.public static Locale localeFromString(String localeStr, Locale defaultLocale)
Locale
from a String of the form en_US_foo into a Locale
with language "en", country "US" and variant "foo". This will parse the output of
Locale.toString()
.localeStr
- The locale String to parse.defaultLocale
- The locale to use if localeStr is null.public static String findDefaultText(String aTextName, Locale locale)
aTextName
- the message keylocale
- the locale the message should be forpublic static String findDefaultText(String aTextName, Locale locale, Object[] params)
aTextName
- the message keylocale
- the locale the message should be forparams
- an array of objects to be substituted into the message textpublic static ResourceBundle findResourceBundle(String aBundleName, Locale locale)
Thread.currentThread().getContextClassLoader()
as the classloader.aBundleName
- the name of the bundle (usually it's FQN classname).locale
- the locale.public static void setDelegatedClassLoader(ClassLoader classLoader)
ClassLoader
to look up the bundle from if none can be found on the current thread's classloaderpublic static void clearBundle(String bundleName)
public static String findText(Class aClass, String aTextName, Locale locale)
findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args)
with aTextName as the default message.public static String findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args)
ModelDriven
Action, then look for message in
the model's class hierarchy (repeat sub-steps listed above).${...}
will be treated as an OGNL expression and evaluated as such.aClass
- the class whose name to use as the start point for the searchaTextName
- the key to find the text message forlocale
- the locale the message should be fordefaultMessage
- the message to be returned if no text message can be found in any
resource bundlepublic static String findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args, ValueStack valueStack)
ModelDriven
Action, then look for message in
the model's class hierarchy (repeat sub-steps listed above).${...}
will be treated as an OGNL expression and evaluated as such.
If a message is not found a WARN log will be logged.aClass
- the class whose name to use as the start point for the searchaTextName
- the key to find the text message forlocale
- the locale the message should be fordefaultMessage
- the message to be returned if no text message can be found in any
resource bundlevalueStack
- the value stack to use to evaluate expressions instead of the
one in the ActionContext ThreadLocalpublic static String findText(ResourceBundle bundle, String aTextName, Locale locale)
${...}
will be treated as an OGNL expression and evaluated as such.public static String findText(ResourceBundle bundle, String aTextName, Locale locale, String defaultMessage, Object[] args)
${...}
will be treated as an OGNL expression and evaluated as such.
If a message is not found a WARN log will be logged.bundle
- the bundleaTextName
- the keylocale
- the localedefaultMessage
- the default message to use if no message was found in the bundleargs
- arguments for the message formatter.public static String findText(ResourceBundle bundle, String aTextName, Locale locale, String defaultMessage, Object[] args, ValueStack valueStack)
${...}
will be treated as an OGNL expression and evaluated as such.
If a message is not found a WARN log will be logged.bundle
- the bundleaTextName
- the keylocale
- the localedefaultMessage
- the default message to use if no message was found in the bundleargs
- arguments for the message formatter.valueStack
- the OGNL value stack.public static void reset()
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.