|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.turbine.services.localization.Localization
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)
Constructor Summary | |
Localization()
|
Method Summary | |
static java.util.ResourceBundle |
getBundle(javax.servlet.http.HttpServletRequest req)
Convenience method to get a ResourceBundle based on name and HTTP Accept-Language header in HttpServletRequest. |
static java.util.ResourceBundle |
getBundle(java.lang.String bundleName)
Convenience method to get a ResourceBundle based on name. |
static 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. |
static java.util.ResourceBundle |
getBundle(java.lang.String bundleName,
java.util.Locale locale)
Convenience method to get a ResourceBundle based on name and Locale. |
static java.util.ResourceBundle |
getBundle(java.lang.String bundleName,
RunData data)
Deprecated. Call getBundle(bundleName, data.getRequest()) instead. |
static 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. |
static java.lang.String |
getDefaultBundleName()
|
static 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. |
static java.util.Locale |
getLocale(java.lang.String languageHeader)
This method parses the Accept-Language header and
attempts to create a Locale out of it. |
protected static LocalizationService |
getService()
Gets the LocalizationService implementation. |
static java.lang.String |
getString(RunData data,
java.lang.String key)
Deprecated. Call getString(key, data.getRequest()) instead. |
static java.lang.String |
getString(java.lang.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. |
static java.lang.String |
getString(java.lang.String key,
javax.servlet.http.HttpServletRequest req)
Pulls a string out of the LocalizationService and attempts to determine the Locale by the Accept-Language header. |
static java.lang.String |
getString(java.lang.String key,
java.util.Locale locale)
|
static java.lang.String |
getString(java.lang.String bundleName,
java.util.Locale locale,
java.lang.String key)
Fetches the localized text from the specified bundle, ignoring any default bundles. |
static java.lang.String |
getString(java.lang.String key,
java.lang.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. |
static void |
setBundle(java.lang.String defaultBundle)
This method sets the name of the default bundle. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Localization()
Method Detail |
public static java.lang.String getString(java.lang.String bundleName, java.util.Locale locale, java.lang.String key)
LocalizationService.getString(String, Locale, String)
public static java.lang.String getString(java.lang.String key)
key
- Name of string.
public static java.lang.String getString(java.lang.String key, java.util.Locale locale)
key
- Name of the text to retrieve.locale
- Locale to get text for.
public static java.lang.String getString(java.lang.String key, javax.servlet.http.HttpServletRequest req)
req
- HttpServletRequest information.key
- Name of string.
public static java.lang.String getString(java.lang.String key, java.lang.String lang)
key
- Name of string.lang
- Desired language for the localized string.
public static java.util.ResourceBundle getBundle(java.lang.String bundleName)
bundleName
- Name of bundle.
public static java.util.ResourceBundle getBundle(java.lang.String bundleName, java.lang.String languageHeader)
bundleName
- Name of bundle.languageHeader
- A String with the language header.
public static java.util.ResourceBundle getBundle(javax.servlet.http.HttpServletRequest req)
req
- HttpServletRequest.
public static java.util.ResourceBundle getBundle(java.lang.String bundleName, javax.servlet.http.HttpServletRequest req)
bundleName
- Name of bundle.req
- HttpServletRequest.
public static java.util.ResourceBundle getBundle(java.lang.String bundleName, java.util.Locale locale)
bundleName
- Name of bundle.locale
- A Locale.
public static void setBundle(java.lang.String defaultBundle)
defaultBundle
- Name of default bundle.public static 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
- HttpServletRequest.
public static java.util.Locale getLocale(java.lang.String languageHeader)
Accept-Language
header and
attempts to create a Locale out of it.
languageHeader
- A String with the language header.
public static java.lang.String getDefaultBundleName()
org.apache.turbine.services.localization.LocalizationService#getDefaultBundle()
protected static final LocalizationService getService()
LocalizationService
implementation.
public static java.lang.String getString(RunData data, java.lang.String key)
public static java.util.ResourceBundle getBundle(java.lang.String bundleName, RunData data)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |