org.apache.fulcrum.localization
Interface SimpleLocalizationService

All Known Subinterfaces:
LocalizationService
All Known Implementing Classes:
DefaultLocalizationService, SimpleLocalizationServiceImpl

public interface 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 535465 2007-05-05 06:58:06Z tv $
Author:
Jon S. Stevens, Daniel Rall, Leonard Richardson, Stephen McConnell, Thomas Vandahl

Field Summary
static String ROLE
           
static String SERVICE_NAME
           
 
Method Summary
 String format(String bundleName, Locale locale, String key, Object arg1)
          Formats a localized value using the provided object.
 String format(String bundleName, Locale locale, String key, Object[] args)
          Formats a localized value using the provided objects.
 String format(String bundleName, Locale locale, String key, Object arg1, Object arg2)
          Formats a localized value using the provided objects.
 ResourceBundle getBundle()
          Convenience method to get the default ResourceBundle.
 ResourceBundle getBundle(String bundleName)
          Returns a ResourceBundle given the bundle name and the default locale information supplied by the configuration.
 ResourceBundle getBundle(String bundleName, Locale locale)
          Convenience method to get a ResourceBundle based on name and Locale.
 String[] getBundleNames()
          Retrieves the list of names of bundles to search by default for ResourceBundle keys (as specified in the config file).
 String getDefaultBundleName()
          Retrieves the name of the default bundle (as specified in the config file), or the first in the list if there are more than one.
 String getDefaultCountry()
          Retrieves the default country (as specified in the config file).
 String getDefaultLanguage()
          Retrieves the default language (as specified in the config file).
 Locale getDefaultLocale()
          Retrieves the default Locale (as created from default language and default country).
 String getString(String bundleName, Locale locale, String key)
          Tries very hard to return a value, looking first in the specified bundle, then searching list of default bundles (giving precedence to earlier bundles over later bundles).
 void setBundle(String defaultBundle)
          This method sets the name of the defaultBundle.
 

Field Detail

ROLE

static final String ROLE

SERVICE_NAME

static final String SERVICE_NAME
Method Detail

getDefaultLanguage

String getDefaultLanguage()
Retrieves the default language (as specified in the config file).


getDefaultCountry

String getDefaultCountry()
Retrieves the default country (as specified in the config file).


getDefaultLocale

Locale getDefaultLocale()
Retrieves the default Locale (as created from default language and default country).


getDefaultBundleName

String getDefaultBundleName()
Retrieves the name of the default bundle (as specified in the config file), or the first in the list if there are more than one.


getBundleNames

String[] getBundleNames()
Retrieves the list of names of bundles to search by default for ResourceBundle keys (as specified in the config file).

Returns:
The list of configured bundle names.

getBundle

ResourceBundle getBundle()
Convenience method to get the default ResourceBundle.

Returns:
A localized ResourceBundle.

getBundle

ResourceBundle getBundle(String bundleName)
Returns a ResourceBundle given the bundle name and the default locale information supplied by the configuration.

Parameters:
bundleName - Name of bundle.
Returns:
A localized ResourceBundle.

getBundle

ResourceBundle getBundle(String bundleName,
                         Locale locale)
Convenience method to get a ResourceBundle based on name and Locale.

Parameters:
bundleName - Name of bundle.
locale - A Locale.
Returns:
A localized ResourceBundle.

getString

String getString(String bundleName,
                 Locale locale,
                 String key)
                 throws MissingResourceException
Tries very hard to return a value, looking first in the specified bundle, then searching list of default bundles (giving precedence to earlier bundles over later bundles).

Parameters:
bundleName - Name of the bundle to look in first.
locale - Locale to get text for.
key - Name of the text to retrieve.
Returns:
Localized text.
Throws:
MissingResourceException

setBundle

void setBundle(String defaultBundle)
This method sets the name of the defaultBundle.

Parameters:
defaultBundle - Name of default bundle.

format

String format(String bundleName,
              Locale locale,
              String key,
              Object arg1)
Formats a localized value using the provided object.

Parameters:
bundleName - The bundle in which to look for the localizable text.
locale - The locale for which to format the text.
key - The identifier for the localized text to retrieve,
arg1 - The object to use as {0} when formatting the localized text.
Returns:
Formatted localized text.
See Also:
format(String, Locale, String, Object[])

format

String format(String bundleName,
              Locale locale,
              String key,
              Object arg1,
              Object arg2)
Formats a localized value using the provided objects.

Parameters:
bundleName - The bundle in which to look for the localizable text.
locale - The locale for which to format the text.
key - The identifier for the localized text to retrieve,
arg1 - The object to use as {0} when formatting the localized text.
arg2 - The object to use as {1} when formatting the localized text.
Returns:
Formatted localized text.
See Also:
format(String, Locale, String, Object[])

format

String format(String bundleName,
              Locale locale,
              String key,
              Object[] args)
Formats a localized value using the provided objects.

Parameters:
bundleName - The bundle in which to look for the localizable text.
locale - The locale for which to format the text.
key - The identifier for the localized text to retrieve,
args - The objects to use as {0}, {1}, etc. when formatting the localized text.
Returns:
Formatted localized text.


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