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$
Author:
Jon S. Stevens, Daniel Rall, Leonard Richardson, Stephen McConnell, Thomas Vandahl
  • Field Details

    • 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:
  • Method Details

    • 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(jakarta.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, jakarta.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(jakarta.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:
      languageHeader - 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.