Package org.apache.fulcrum.localization
Class DefaultLocalizationService
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.fulcrum.localization.SimpleLocalizationServiceImpl
org.apache.fulcrum.localization.DefaultLocalizationService
- All Implemented Interfaces:
- org.apache.avalon.framework.activity.Initializable,- org.apache.avalon.framework.configuration.Configurable,- org.apache.avalon.framework.logger.LogEnabled,- LocalizationService,- SimpleLocalizationService
public class DefaultLocalizationService
extends SimpleLocalizationServiceImpl
implements LocalizationService
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 SimpleLocalizationServiceImpl.getString(String, Locale, String), or one of
 four methods to retrieve a ResourceBundle:
 
- getBundle("MyBundleName")
- getBundle("MyBundleName", httpAcceptLanguageHeader)
- etBundle("MyBundleName", HttpServletRequest)
- getBundle("MyBundleName", Locale)
- etc.
- Version:
- $Id$ avalon.component name="localization" lifestyle="singleton" avalon.service type="org.apache.fulcrum.localization.LocalizationService"
- Author:
- Jonas Maurus, Jon S. Stevens, Frank Y. Kim, Daniel Rall, Leonard Richardson, Stephen McConnell, Thomas Vandahl
- 
Field SummaryFields inherited from interface org.apache.fulcrum.localization.LocalizationServiceACCEPT_LANGUAGE, ROLE, SERVICE_NAMEFields inherited from interface org.apache.fulcrum.localization.SimpleLocalizationServiceROLE, SERVICE_NAME
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptiongetBundle(jakarta.servlet.http.HttpServletRequest req) This method returns a ResourceBundle given the Locale information supplied in the HTTP "Accept-Language" header which is stored in HttpServletRequest.Convenience method to get aResourceBundlebased on name and HTTPAccept-Languageheader from aHttpServletRequest.This method returns a ResourceBundle given the bundle name and the Locale information supplied in the HTTP "Accept-Language" header.getLocale(jakarta.servlet.http.HttpServletRequest req) Attempts to pull theAccept-Languageheader out of theHttpServletRequestobject and then parse it.Parses theAccept-Languageheader and attempts to create aLocalefrom it.Methods inherited from class org.apache.fulcrum.localization.SimpleLocalizationServiceImplconfigure, format, format, format, getBundle, getBundle, getBundle, getBundleNames, getDefaultBundleName, getDefaultCountry, getDefaultLanguage, getDefaultLocale, getString, getString, getStringOrNull, initBundleNames, initialize, setBundleMethods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabledenableLogging, getLogger, setupLogger, setupLogger, setupLoggerMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.fulcrum.localization.SimpleLocalizationServiceformat, format, format, getBundle, getBundle, getBundle, getBundleNames, getDefaultBundleName, getDefaultCountry, getDefaultLanguage, getDefaultLocale, getString, getString, setBundle
- 
Constructor Details- 
DefaultLocalizationServicepublic DefaultLocalizationService()Creates a new instance.
 
- 
- 
Method Details- 
getBundleThis method returns a ResourceBundle given the bundle name and the Locale information supplied in the HTTP "Accept-Language" header.- Specified by:
- getBundlein interface- LocalizationService
- Parameters:
- bundleName- Name of bundle.
- languageHeader- A String with the language header.
- Returns:
- A localized ResourceBundle.
- See Also:
 
- 
getBundleThis method returns a ResourceBundle given the Locale information supplied in the HTTP "Accept-Language" header which is stored in HttpServletRequest.- Specified by:
- getBundlein interface- LocalizationService
- Parameters:
- req- HttpServletRequest.
- Returns:
- A localized ResourceBundle.
 
- 
getBundleDescription copied from interface:LocalizationServiceConvenience method to get aResourceBundlebased on name and HTTPAccept-Languageheader from aHttpServletRequest.- Specified by:
- getBundlein interface- LocalizationService
- Parameters:
- bundleName- Name of the bundle to use if the request's locale cannot be resolved.
- req- HttpServletRequest.
- Returns:
- A localized ResourceBundle.
- See Also:
 
- 
getLocaleDescription copied from interface:LocalizationServiceAttempts to pull theAccept-Languageheader out of theHttpServletRequestobject and then parse it. If the header is not present, it will return anullLocale.- Specified by:
- getLocalein interface- LocalizationService
- Parameters:
- req- The HTTP request to parse the- Accept-Languageof.
- Returns:
- The parsed locale.
 
- 
getLocaleDescription copied from interface:LocalizationServiceParses theAccept-Languageheader and attempts to create aLocalefrom it.- Specified by:
- getLocalein interface- LocalizationService
- Parameters:
- header- The language header (i.e.- en, es;q=0.8, zh-TW;q=0.1), or- nullfor the locale corresponding to the default language and country.
- Returns:
- The parsed locale, or a locale corresponding to the language and country defaults.
 
 
-