Package org.apache.fulcrum.localization
Interface LocalizationService
- All Superinterfaces:
SimpleLocalizationService
- All Known Implementing Classes:
DefaultLocalizationService
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$
- Author:
- Jon S. Stevens, Daniel Rall, Leonard Richardson, Stephen McConnell, Thomas Vandahl
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiongetBundle
(jakarta.servlet.http.HttpServletRequest req) Convenience method to get a ResourceBundle based on HTTP Accept-Language header in HttpServletRequest.Convenience method to get aResourceBundle
based on name and HTTPAccept-Language
header from aHttpServletRequest
.Convenience method to get a ResourceBundle based on name and HTTPAccept-Language
header.getLocale
(jakarta.servlet.http.HttpServletRequest req) Attempts to pull theAccept-Language
header out of theHttpServletRequest
object and then parse it.Parses theAccept-Language
header and attempts to create aLocale
from it.Methods inherited from interface org.apache.fulcrum.localization.SimpleLocalizationService
format, format, format, getBundle, getBundle, getBundle, getBundleNames, getDefaultBundleName, getDefaultCountry, getDefaultLanguage, getDefaultLocale, getString, getString, setBundle
-
Field Details
-
ROLE
-
SERVICE_NAME
-
ACCEPT_LANGUAGE
A constant for the HTTPAccept-Language
header.- See Also:
-
-
Method Details
-
getBundle
Convenience method to get a ResourceBundle based on name and HTTPAccept-Language
header.- Parameters:
bundleName
- Name of bundle.languageHeader
- A String with the language header.- Returns:
- A localized ResourceBundle.
-
getBundle
Convenience method to get a ResourceBundle based on HTTP Accept-Language header in HttpServletRequest.- Parameters:
req
- The HTTP request to parse theAccept-Language
of.- Returns:
- A localized ResourceBundle.
-
getBundle
Convenience method to get aResourceBundle
based on name and HTTPAccept-Language
header from aHttpServletRequest
.- Parameters:
bundleName
- Name of bundle.req
- The HTTP request to parse theAccept-Language
of.- Returns:
- A localized ResourceBundle.
-
getLocale
Attempts to pull theAccept-Language
header out of theHttpServletRequest
object and then parse it. If the header is not present, it will return anull
Locale
.- Parameters:
req
- The HTTP request to parse theAccept-Language
of.- Returns:
- The parsed locale.
-
getLocale
Parses theAccept-Language
header and attempts to create aLocale
from it.- Parameters:
languageHeader
- The language header (i.e.en, es;q=0.8, zh-TW;q=0.1
), ornull
for the locale corresponding to the default language and country.- Returns:
- The parsed locale, or a locale corresponding to the language and country defaults.
-