|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
Provides localization functionality using the interface provided
by ResourceBundle, plus leverages a "search path"
style traversal of the ResourceBundle objects named by
the locale.default.bundles to discover a value for a
given key.
It is suggested that one handle
dealing with concatenated messages
using MessageFormat and properties files.
| Field Summary | |
static java.lang.String |
ACCEPT_LANGUAGE
A constant for the HTTP Accept-Language header. |
static java.lang.String |
SERVICE_NAME
The name of this service. |
| Method Summary | |
java.lang.String |
format(java.lang.String bundleName,
java.util.Locale locale,
java.lang.String key,
java.lang.Object arg1)
Formats a localized value using the provided object. |
java.lang.String |
format(java.lang.String bundleName,
java.util.Locale locale,
java.lang.String key,
java.lang.Object[] args)
Formats a localized value using the provided objects. |
java.lang.String |
format(java.lang.String bundleName,
java.util.Locale locale,
java.lang.String key,
java.lang.Object arg1,
java.lang.Object arg2)
Formats a localized value using the provided objects. |
java.util.ResourceBundle |
getBundle()
Convenience method to get a default ResourceBundle. |
java.util.ResourceBundle |
getBundle(javax.servlet.http.HttpServletRequest req)
Convenience method to get a ResourceBundle based on HTTP Accept-Language header in HttpServletRequest. |
java.util.ResourceBundle |
getBundle(java.lang.String bundleName)
Returns a ResourceBundle given the bundle name and the default locale information supplied by the configuration. |
java.util.ResourceBundle |
getBundle(java.lang.String bundleName,
javax.servlet.http.HttpServletRequest req)
Convenience method to get a ResourceBundle based on name and HTTP Accept-Language header in HttpServletRequest. |
java.util.ResourceBundle |
getBundle(java.lang.String bundleName,
java.util.Locale locale)
Convenience method to get a ResourceBundle based on name and Locale. |
java.util.ResourceBundle |
getBundle(java.lang.String bundleName,
java.lang.String languageHeader)
Convenience method to get a ResourceBundle based on name and HTTP Accept-Language header. |
java.lang.String[] |
getBundleNames()
Retrieves the list of names of bundles to search by default for ResourceBundle keys (as specified in the config
file). |
java.lang.String |
getDefaultBundleName()
Retrieves the name of the default bundle (as specified in the config file), or the first in the list if there are more than one. |
java.lang.String |
getDefaultCountry()
Retrieves the default country (as specified in the config file). |
java.lang.String |
getDefaultLanguage()
Retrieves the default language (as specified in the config file). |
java.util.Locale |
getLocale(javax.servlet.http.HttpServletRequest req)
Attempts to pull the Accept-Language header out of
the HttpServletRequest object and then parse it.
|
java.util.Locale |
getLocale(java.lang.String languageHeader)
This method parses the Accept-Language header and
attempts to create a Locale out of it. |
java.lang.String |
getString(java.lang.String bundleName,
java.util.Locale locale,
java.lang.String key)
Tries very hard to return a value, looking first in the specified bundle, then searching list of default bundles (giving precedence to earlier bundles over later bundles). |
void |
setBundle(java.lang.String defaultBundle)
This method sets the name of the defaultBundle. |
| Methods inherited from interface org.apache.turbine.services.Service |
getConfiguration, getName, getProperties, setName, setServiceBroker |
| Methods inherited from interface org.apache.turbine.services.Initable |
getInit, init, init, setInitableBroker, shutdown |
| Field Detail |
public static final java.lang.String SERVICE_NAME
public static final java.lang.String ACCEPT_LANGUAGE
Accept-Language header.
| Method Detail |
public java.lang.String getDefaultLanguage()
public java.lang.String getDefaultCountry()
public java.lang.String getDefaultBundleName()
public java.lang.String[] getBundleNames()
ResourceBundle keys (as specified in the config
file).
public java.util.ResourceBundle getBundle()
public java.util.ResourceBundle getBundle(java.lang.String bundleName)
bundleName - Name of bundle.
public java.util.ResourceBundle getBundle(java.lang.String bundleName,
java.lang.String languageHeader)
bundleName - Name of bundle.languageHeader - A String with the language header.
public java.util.ResourceBundle getBundle(javax.servlet.http.HttpServletRequest req)
req - The HTTP request to parse the
Accept-Language of.
public java.util.ResourceBundle getBundle(java.lang.String bundleName,
javax.servlet.http.HttpServletRequest req)
bundleName - Name of bundle.req - The HTTP request to parse the
Accept-Language of.
public java.util.ResourceBundle getBundle(java.lang.String bundleName,
java.util.Locale locale)
bundleName - Name of bundle.locale - A Locale.
public java.util.Locale getLocale(javax.servlet.http.HttpServletRequest req)
Accept-Language header out of
the HttpServletRequest object and then parse it.
If the header is not present, it will return a
null Locale.
req - The HTTP request to parse the
Accept-Language of.
public java.util.Locale getLocale(java.lang.String languageHeader)
Accept-Language header and
attempts to create a Locale out of it.
languageHeader - The Accept-Language HTTP
header.
public void setBundle(java.lang.String defaultBundle)
defaultBundle - Name of default bundle.
public java.lang.String getString(java.lang.String bundleName,
java.util.Locale locale,
java.lang.String key)
bundleName - Name of the bundle to look in first.locale - Locale to get text for.key - Name of the text to retrieve.
public java.lang.String format(java.lang.String bundleName,
java.util.Locale locale,
java.lang.String key,
java.lang.Object arg1)
bundleName - The bundle in which to look for the localizable text.locale - The locale for which to format the text.key - The identifier for the localized text to retrieve,arg1 - The object to use as {0} when formatting the localized text.
format(String, Locale, String, Object[])
public java.lang.String format(java.lang.String bundleName,
java.util.Locale locale,
java.lang.String key,
java.lang.Object arg1,
java.lang.Object arg2)
bundleName - The bundle in which to look for the localizable text.locale - The locale for which to format the text.key - The identifier for the localized text to retrieve,arg1 - The object to use as {0} when formatting the localized text.arg2 - The object to use as {1} when formatting the localized text.
format(String, Locale, String, Object[])
public java.lang.String format(java.lang.String bundleName,
java.util.Locale locale,
java.lang.String key,
java.lang.Object[] args)
bundleName - The bundle in which to look for the localizable text.locale - The locale for which to format the text.key - The identifier for the localized text to retrieve,args - The objects to use as {0}, {1}, etc. when
formatting the localized text.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||