| java.lang.Object org.apache.turbine.services.localization.Localization
Localization | abstract public class Localization (Code) | | Wrapper around the TurbineLocalization Service that makes it easy
to grab something from the service and make the code cleaner.
Instead of typing:
((LocalizationService)TurbineServices.getInstance()
.getService(LocalizationService.SERVICE_NAME))
.getBundle(data)
.getString(str)
Now you only need to type:
Localization.getString(str)
author: Jon S. Stevens author: Daniel Rall version: $Id: Localization.java 534527 2007-05-02 16:10:59Z tv $ |
Method Summary | |
public static 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 static 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 static String | format(String bundleName, Locale locale, String key, Object[] args) 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: args - The objects to use as {0}, {1}, etc. | public static ResourceBundle | getBundle(String bundleName) Convenience method to get a ResourceBundle based on name.
Parameters: bundleName - Name of bundle. | public static ResourceBundle | getBundle(String bundleName, String languageHeader) Convenience method to get a ResourceBundle based on name and
HTTP Accept-Language header.
Parameters: bundleName - Name of bundle. Parameters: languageHeader - A String with the language header. | public static ResourceBundle | getBundle(HttpServletRequest req) Convenience method to get a ResourceBundle based on name and
HTTP Accept-Language header in HttpServletRequest.
Parameters: req - HttpServletRequest. | public static ResourceBundle | getBundle(String bundleName, HttpServletRequest req) Convenience method to get a ResourceBundle based on name and
HTTP Accept-Language header in HttpServletRequest.
Parameters: bundleName - Name of bundle. Parameters: req - HttpServletRequest. | public static ResourceBundle | getBundle(String bundleName, Locale locale) Convenience method to get a ResourceBundle based on name and
Locale.
Parameters: bundleName - Name of bundle. Parameters: locale - A Locale. | public static ResourceBundle | getBundle(String bundleName, RunData data) | public static String | getDefaultBundleName() | public static Locale | getLocale(HttpServletRequest req) Attempts to pull the Accept-Language header out of
the HttpServletRequest object and then parse it. | public static Locale | getLocale(String languageHeader) This method parses the Accept-Language header and
attempts to create a Locale out of it.
Parameters: languageHeader - A String with the language header. | final protected static LocalizationService | getService() Gets the LocalizationService implementation. | public static String | getString(String bundleName, Locale locale, String key) Fetches the localized text from the specified bundle, ignoring
any default bundles. | public static String | getString(String key) Pulls a string out of the LocalizationService with the default
locale values of what is defined in the
TurbineResources.properties file for the
locale.default.language and locale.default.country property
values. | public static String | getString(String key, Locale locale) Parameters: key - Name of the text to retrieve. Parameters: locale - Locale to get text for. | public static String | getString(String key, HttpServletRequest req) Pulls a string out of the LocalizationService and attempts to
determine the Locale by the Accept-Language header. | public static String | getString(String key, String lang) Convenience method that pulls a localized string off the
LocalizationService using the default ResourceBundle name
defined in the TurbineResources.properties file and the
specified language name in ISO format.
Parameters: key - Name of string. Parameters: lang - Desired language for the localized string. | public static String | getString(RunData data, String key) | public static void | setBundle(String defaultBundle) This method sets the name of the default bundle. |
format | public static 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: Localization.format(String,Locale,String,Object[]) |
format | public static 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: Localization.format(String,Locale,String,Object[]) |
format | public static String format(String bundleName, Locale locale, String key, Object[] args)(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: args - The objects to use as {0}, {1}, etc. whenformatting the localized text. Formatted localized text. |
getBundle | public static ResourceBundle getBundle(String bundleName)(Code) | | Convenience method to get a ResourceBundle based on name.
Parameters: bundleName - Name of bundle. A localized ResourceBundle. |
getBundle | public static ResourceBundle getBundle(String bundleName, String languageHeader)(Code) | | Convenience method to get a ResourceBundle based on name and
HTTP Accept-Language header.
Parameters: bundleName - Name of bundle. Parameters: languageHeader - A String with the language header. A localized ResourceBundle. |
getBundle | public static ResourceBundle getBundle(HttpServletRequest req)(Code) | | Convenience method to get a ResourceBundle based on name and
HTTP Accept-Language header in HttpServletRequest.
Parameters: req - HttpServletRequest. A localized ResourceBundle. |
getBundle | public static ResourceBundle getBundle(String bundleName, HttpServletRequest req)(Code) | | Convenience method to get a ResourceBundle based on name and
HTTP Accept-Language header in HttpServletRequest.
Parameters: bundleName - Name of bundle. Parameters: req - HttpServletRequest. A localized ResourceBundle. |
getBundle | public static ResourceBundle getBundle(String bundleName, Locale locale)(Code) | | Convenience method to get a ResourceBundle based on name and
Locale.
Parameters: bundleName - Name of bundle. Parameters: locale - A Locale. A localized ResourceBundle. |
getLocale | public static Locale getLocale(HttpServletRequest req)(Code) | | Attempts to pull the Accept-Language header out of
the HttpServletRequest object and then parse it. If the header
is not present, it will return a null Locale.
Parameters: req - HttpServletRequest. A Locale. |
getLocale | public static Locale getLocale(String languageHeader)(Code) | | This method parses the Accept-Language header and
attempts to create a Locale out of it.
Parameters: languageHeader - A String with the language header. A Locale. |
getService | final protected static LocalizationService getService()(Code) | | Gets the LocalizationService implementation.
the LocalizationService implementation. |
getString | public static String getString(String key)(Code) | | Pulls a string out of the LocalizationService with the default
locale values of what is defined in the
TurbineResources.properties file for the
locale.default.language and locale.default.country property
values. If those cannot be found, then the JVM defaults are
used.
Parameters: key - Name of string. A localized String. |
getString | public static String getString(String key, Locale locale)(Code) | | Parameters: key - Name of the text to retrieve. Parameters: locale - Locale to get text for. Localized text. |
getString | public static String getString(String key, HttpServletRequest req)(Code) | | Pulls a string out of the LocalizationService and attempts to
determine the Locale by the Accept-Language header. If that
header is not present, it will fall back to using the locale
values of what is defined in the TurbineResources.properties
file for the locale.default.language and locale.default.country
property values. If those cannot be found, then the JVM
defaults are used.
Parameters: req - HttpServletRequest information. Parameters: key - Name of string. A localized String. |
getString | public static String getString(String key, String lang)(Code) | | Convenience method that pulls a localized string off the
LocalizationService using the default ResourceBundle name
defined in the TurbineResources.properties file and the
specified language name in ISO format.
Parameters: key - Name of string. Parameters: lang - Desired language for the localized string. A localized string. |
setBundle | public static void setBundle(String defaultBundle)(Code) | | This method sets the name of the default bundle.
Parameters: defaultBundle - Name of default bundle. |
|
|