| org.apache.turbine.services.TurbineBaseService org.apache.turbine.services.localization.TurbineLocalizationService
TurbineLocalizationService | public class TurbineLocalizationService extends TurbineBaseService implements LocalizationService(Code) | | This class is the single point of access to all localization
resources. It caches different ResourceBundles for different
Locales.
Usage example:
LocalizationService ls = (LocalizationService) TurbineServices
.getInstance().getService(LocalizationService.SERVICE_NAME);
Then call one of four methods to retrieve a ResourceBundle:
- getBundle("MyBundleName")
- getBundle("MyBundleName", httpAcceptLanguageHeader)
- etBundle("MyBundleName", HttpServletRequest)
- getBundle("MyBundleName", Locale)
- etc.
author: Jonas Maurus author: Jon S. Stevens author: Frank Y. Kim author: Daniel Rall author: Leonard Richardson author: Henning P. Schmiedehausen version: $Id: TurbineLocalizationService.java 534527 2007-05-02 16:10:59Z tv $ |
Method Summary | |
public String | format(String bundleName, Locale locale, String key, Object arg1) Formats a localized value using the provided object.
Parameters: bundleName - The bundle in which to look for the localizable text. Parameters: locale - The locale for which to format the text. Parameters: key - The identifier for the localized text to retrieve, Parameters: arg1 - The object to use as {0} when formatting the localized text. | public String | format(String bundleName, Locale locale, String key, Object arg1, Object arg2) Formats a localized value using the provided objects.
Parameters: bundleName - The bundle in which to look for the localizable text. Parameters: locale - The locale for which to format the text. Parameters: key - The identifier for the localized text to retrieve, Parameters: arg1 - The object to use as {0} when formatting the localized text. Parameters: arg2 - The object to use as {1} when formatting the localized text. | public String | format(String bundleName, Locale locale, String key, Object[] args) Looks up the value for key in the
ResourceBundle referenced by
bundleName , then formats that value for the
specified Locale using args .
Parameters: bundleName - The bundle in which to look for the localizable text. Parameters: locale - The locale for which to format the text. Parameters: key - The identifier for the localized text to retrieve, Parameters: args - The objects to use when formatting the localized text. | public ResourceBundle | getBundle() This method returns a ResourceBundle given the bundle name
"DEFAULT" and the default Locale information supplied in
TurbineProperties. | public ResourceBundle | getBundle(String bundleName) This method returns a ResourceBundle given the bundle name and
the default Locale information supplied in TurbineProperties.
Parameters: bundleName - Name of bundle. | public ResourceBundle | getBundle(String bundleName, String languageHeader) This method returns a ResourceBundle given the bundle name and
the Locale information supplied in the HTTP "Accept-Language"
header.
Parameters: bundleName - Name of bundle. Parameters: languageHeader - A String with the language header. | public ResourceBundle | getBundle(HttpServletRequest req) This method returns a ResourceBundle given the Locale
information supplied in the HTTP "Accept-Language" header which
is stored in HttpServletRequest.
Parameters: req - HttpServletRequest. | public ResourceBundle | getBundle(String bundleName, HttpServletRequest req) This method returns a ResourceBundle given the bundle name and
the Locale information supplied in the HTTP "Accept-Language"
header which is stored in HttpServletRequest.
Parameters: bundleName - Name of the bundle to use if the request'slocale cannot be resolved. Parameters: req - HttpServletRequest. | public ResourceBundle | getBundle(RunData data) This method returns a ResourceBundle given the Locale
information supplied in the HTTP "Accept-Language" header which
is stored in RunData.
Parameters: data - Turbine information. | public ResourceBundle | getBundle(String bundleName, RunData data) This method returns a ResourceBundle given the bundle name and
the Locale information supplied in the HTTP "Accept-Language"
header which is stored in RunData.
Parameters: bundleName - Name of bundle. Parameters: data - Turbine information. | public ResourceBundle | getBundle(String bundleName, Locale locale) This method returns a ResourceBundle for the given bundle name
and the given Locale.
Parameters: bundleName - Name of bundle (or null for thedefault bundle). Parameters: locale - The locale (or null for the localeindicated by the default language and country). | public String[] | getBundleNames() | public String | getDefaultBundleName() Retrieves the name of the default bundle (as specified in the
config file). | public String | getDefaultCountry() Retrieves the default country (specified in the config file). | public String | getDefaultLanguage() Retrieves the default language (specified in the config file). | final public Locale | getLocale(HttpServletRequest req) | public Locale | getLocale(String header) | public String | getString(String bundleName, Locale locale, String key) | final protected String | getStringOrNull(ResourceBundle rb, String key) Gets localized text from a bundle if it's there. | public void | init() Called the first time the Service is used. | protected void | initBundleNames(String[] ignored) Initialize list of default bundle names. | public void | setBundle(String defaultBundle) This method sets the name of the first bundle in the search
list (the "default" bundle). |
TurbineLocalizationService | public TurbineLocalizationService()(Code) | | Constructor.
|
format | public String format(String bundleName, Locale locale, String key, Object arg1)(Code) | | Formats a localized value using the provided object.
Parameters: bundleName - The bundle in which to look for the localizable text. Parameters: locale - The locale for which to format the text. Parameters: key - The identifier for the localized text to retrieve, Parameters: arg1 - The object to use as {0} when formatting the localized text. Formatted localized text. See Also: TurbineLocalizationService.format(String,Locale,String,Object[]) |
format | public String format(String bundleName, Locale locale, String key, Object arg1, Object arg2)(Code) | | Formats a localized value using the provided objects.
Parameters: bundleName - The bundle in which to look for the localizable text. Parameters: locale - The locale for which to format the text. Parameters: key - The identifier for the localized text to retrieve, Parameters: arg1 - The object to use as {0} when formatting the localized text. Parameters: arg2 - The object to use as {1} when formatting the localized text. Formatted localized text. See Also: TurbineLocalizationService.format(String,Locale,String,Object[]) |
format | public String format(String bundleName, Locale locale, String key, Object[] args)(Code) | | Looks up the value for key in the
ResourceBundle referenced by
bundleName , then formats that value for the
specified Locale using args .
Parameters: bundleName - The bundle in which to look for the localizable text. Parameters: locale - The locale for which to format the text. Parameters: key - The identifier for the localized text to retrieve, Parameters: args - The objects to use when formatting the localized text. Localized, formatted text identified bykey . |
getBundle | public ResourceBundle getBundle()(Code) | | This method returns a ResourceBundle given the bundle name
"DEFAULT" and the default Locale information supplied in
TurbineProperties.
A localized ResourceBundle. |
getBundle | public ResourceBundle getBundle(String bundleName)(Code) | | This method returns a ResourceBundle given the bundle name and
the default Locale information supplied in TurbineProperties.
Parameters: bundleName - Name of bundle. A localized ResourceBundle. |
getBundle | public ResourceBundle getBundle(String bundleName, String languageHeader)(Code) | | This method returns a ResourceBundle given the bundle name and
the Locale information supplied in the HTTP "Accept-Language"
header.
Parameters: bundleName - Name of bundle. Parameters: languageHeader - A String with the language header. A localized ResourceBundle. |
getBundle | public ResourceBundle getBundle(HttpServletRequest req)(Code) | | This method returns a ResourceBundle given the Locale
information supplied in the HTTP "Accept-Language" header which
is stored in HttpServletRequest.
Parameters: req - HttpServletRequest. A localized ResourceBundle. |
getBundle | public ResourceBundle getBundle(String bundleName, HttpServletRequest req)(Code) | | This method returns a ResourceBundle given the bundle name and
the Locale information supplied in the HTTP "Accept-Language"
header which is stored in HttpServletRequest.
Parameters: bundleName - Name of the bundle to use if the request'slocale cannot be resolved. Parameters: req - HttpServletRequest. A localized ResourceBundle. |
getBundle | public ResourceBundle getBundle(RunData data)(Code) | | This method returns a ResourceBundle given the Locale
information supplied in the HTTP "Accept-Language" header which
is stored in RunData.
Parameters: data - Turbine information. A localized ResourceBundle. |
getBundle | public ResourceBundle getBundle(String bundleName, RunData data)(Code) | | This method returns a ResourceBundle given the bundle name and
the Locale information supplied in the HTTP "Accept-Language"
header which is stored in RunData.
Parameters: bundleName - Name of bundle. Parameters: data - Turbine information. A localized ResourceBundle. |
getBundle | public ResourceBundle getBundle(String bundleName, Locale locale)(Code) | | This method returns a ResourceBundle for the given bundle name
and the given Locale.
Parameters: bundleName - Name of bundle (or null for thedefault bundle). Parameters: locale - The locale (or null for the localeindicated by the default language and country). A localized ResourceBundle. |
getDefaultCountry | public String getDefaultCountry()(Code) | | Retrieves the default country (specified in the config file).
|
getDefaultLanguage | public String getDefaultLanguage()(Code) | | Retrieves the default language (specified in the config file).
|
getStringOrNull | final protected String getStringOrNull(ResourceBundle rb, String key)(Code) | | Gets localized text from a bundle if it's there. Otherwise,
returns null (ignoring a possible
MissingResourceException ).
|
initBundleNames | protected void initBundleNames(String[] ignored)(Code) | | Initialize list of default bundle names.
Parameters: ignored - Ignored. |
setBundle | public void setBundle(String defaultBundle)(Code) | | This method sets the name of the first bundle in the search
list (the "default" bundle).
Parameters: defaultBundle - Name of default bundle. |
|
|