Package 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
Fields -
Method Summary
Modifier and TypeMethodDescriptionFormats a localized value using the provided object.Formats a localized value using the provided objects.Formats a localized value using the provided objects.Convenience method to get the defaultResourceBundle
.Returns a ResourceBundle given the bundle name and the default locale information supplied by the configuration.Convenience method to get a ResourceBundle based on name and Locale.String[]
Retrieves the list of names of bundles to search by default forResourceBundle
keys (as specified in the config file).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.Retrieves the default country (as specified in the config file).Retrieves the default language (as specified in the config file).Retrieves the default Locale (as created from default language and default country).Returns the value for the key in the default bundle and the default locale.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
This method sets the name of the defaultBundle.
-
Field Details
-
ROLE
-
SERVICE_NAME
-
-
Method Details
-
getDefaultLanguage
String getDefaultLanguage()Retrieves the default language (as specified in the config file).- Returns:
- the default language
-
getDefaultCountry
String getDefaultCountry()Retrieves the default country (as specified in the config file).- Returns:
- the default country
-
getDefaultLocale
Locale getDefaultLocale()Retrieves the default Locale (as created from default language and default country).- Returns:
- the default locale
-
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.- Returns:
- the default bundle name
-
getBundleNames
String[] getBundleNames()Retrieves the list of names of bundles to search by default forResourceBundle
keys (as specified in the config file).- Returns:
- The list of configured bundle names.
-
getBundle
ResourceBundle getBundle()Convenience method to get the defaultResourceBundle
.- Returns:
- A localized
ResourceBundle
.
-
getBundle
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
Convenience method to get a ResourceBundle based on name and Locale.- Parameters:
bundleName
- Name of bundle.locale
- A Locale.- Returns:
- A localized ResourceBundle.
-
getString
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
- if the resource is not found
-
getString
Returns the value for the key in the default bundle and the default locale.- Parameters:
key
- The key to retrieve the value for.- Returns:
- The value mapped to the key.
-
setBundle
This method sets the name of the defaultBundle.- Parameters:
defaultBundle
- Name of default bundle.
-
format
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
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
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.
-