|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.xwork.util.LocalizedTextUtil
Provides support for localization in XWork. Resource bundles are searched in the following order:
Constructor Summary | |
LocalizedTextUtil()
|
Method Summary | |
static void |
addDefaultResourceBundle(String resourceBundleName)
Add's the bundle to the internal list of default bundles. |
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,
OgnlValueStack 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,
OgnlValueStack 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 |
setReloadBundles(boolean reloadBundles)
Should resorce bundles be reloaded. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public LocalizedTextUtil()
Method Detail |
public static void clearDefaultResourceBundles()
public static void setReloadBundles(boolean reloadBundles)
webwork.i18n.reload
property.
reloadBundles
- reload bundles?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 for
public 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 text
public 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 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.
findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args)
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 bundle
public static String findText(Class aClass, String aTextName, Locale locale, String defaultMessage, Object[] args, OgnlValueStack 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 ThreadLocal
public static String findText(ResourceBundle bundle, String aTextName, Locale locale)
${...}
will be treated as an OGNL expression and evaluated as such.
findText(java.util.ResourceBundle, String, java.util.Locale, String, Object[])
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, OgnlValueStack 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()
|
XWork Project Page | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |