org.apache.fulcrum.localization
Interface LocalizationService

All Superinterfaces:
SimpleLocalizationService
All Known Implementing Classes:
DefaultLocalizationService

public interface LocalizationService
extends SimpleLocalizationService

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.

Version:
$Id: LocalizationService.java 645885 2008-04-08 12:50:57Z tv $
Author:
Jon S. Stevens, Daniel Rall, Leonard Richardson, Stephen McConnell, Thomas Vandahl

Field Summary
static String ACCEPT_LANGUAGE
          A constant for the HTTP Accept-Language header.
static String ROLE
           
static String SERVICE_NAME
           
 
Method Summary
 ResourceBundle getBundle(javax.servlet.http.HttpServletRequest req)
          Convenience method to get a ResourceBundle based on HTTP Accept-Language header in HttpServletRequest.
 ResourceBundle getBundle(String bundleName, javax.servlet.http.HttpServletRequest req)
          Convenience method to get a ResourceBundle based on name and HTTP Accept-Language header from a HttpServletRequest.
 ResourceBundle getBundle(String bundleName, String languageHeader)
          Convenience method to get a ResourceBundle based on name and HTTP Accept-Language header.
 Locale getLocale(javax.servlet.http.HttpServletRequest req)
          Attempts to pull the Accept-Language header out of the HttpServletRequest object and then parse it.
 Locale getLocale(String languageHeader)
          Parses the Accept-Language header and attempts to create a Locale from it.
 
Methods inherited from interface org.apache.fulcrum.localization.SimpleLocalizationService
format, format, format, getBundle, getBundle, getBundle, getBundleNames, getDefaultBundleName, getDefaultCountry, getDefaultLanguage, getDefaultLocale, getString, setBundle
 

Field Detail

ROLE

static final String ROLE

SERVICE_NAME

static final String SERVICE_NAME

ACCEPT_LANGUAGE

static final String ACCEPT_LANGUAGE
A constant for the HTTP Accept-Language header.

See Also:
Constant Field Values
Method Detail

getBundle

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.
languageHeader - A String with the language header.
Returns:
A localized ResourceBundle.

getBundle

ResourceBundle getBundle(javax.servlet.http.HttpServletRequest req)
Convenience method to get a ResourceBundle based on HTTP Accept-Language header in HttpServletRequest.

Parameters:
req - The HTTP request to parse the Accept-Language of.
Returns:
A localized ResourceBundle.

getBundle

ResourceBundle getBundle(String bundleName,
                         javax.servlet.http.HttpServletRequest req)
Convenience method to get a ResourceBundle based on name and HTTP Accept-Language header from a HttpServletRequest.

Parameters:
bundleName - Name of bundle.
req - The HTTP request to parse the Accept-Language of.
Returns:
A localized ResourceBundle.

getLocale

Locale getLocale(javax.servlet.http.HttpServletRequest req)
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 - The HTTP request to parse the Accept-Language of.
Returns:
The parsed locale.

getLocale

Locale getLocale(String languageHeader)
Parses the Accept-Language header and attempts to create a Locale from it.

Parameters:
header - The language header (i.e. en, es;q=0.8, zh-TW;q=0.1), or null for the locale corresponding to the default language and country.
Returns:
The parsed locale, or a locale corresponding to the language and country defaults.


Copyright © 2005-2009 The Apache Software Foundation. All Rights Reserved.