org.codehaus.plexus.i18n
public class DefaultI18N extends AbstractLogEnabled implements I18N, Initializable
UNKNOWN: role="org.codehaus.plexus.i18n.I18N"
Field Summary | |
---|---|
String[] | bundleNames |
HashMap | bundles |
String | defaultBundleName |
String | defaultCountry |
String | defaultLanguage |
Locale | defaultLocale |
boolean | devMode |
static Object[] | NO_ARGS |
Method Summary | |
---|---|
ResourceBundle | cacheBundle(String bundleName, Locale locale)
Caches the named bundle for fast lookups. |
ResourceBundle | findBundleByLocale(String bundleName, Locale locale, Map bundlesByLocale) Retrieves the bundle most closely matching first against the supplied inputs, then against the defaults. Use case: some clients send a HTTP Accept-Language header with a value of only the language to use (i.e. |
String | format(String key, Object arg1) |
String | format(String key, Object arg1, Object arg2) |
String | format(String bundleName, Locale locale, String key, Object arg1) |
String | format(String bundleName, Locale locale, String key, Object arg1, Object arg2) |
String | format(String bundleName, Locale locale, String key, Object[] args)
Looks up the value for key in the
ResourceBundle referenced by
bundleName , then formats that value for the
specified Locale using args .
|
ResourceBundle | getBundle() |
ResourceBundle | getBundle(String bundleName) |
ResourceBundle | getBundle(String bundleName, String languageHeader)
This method returns a ResourceBundle given the bundle name and
the Locale information supplied in the HTTP "Accept-Language"
header.
|
ResourceBundle | getBundle(String bundleName, Locale locale)
This method returns a ResourceBundle for the given bundle name
and the given Locale.
|
ResourceBundle | getBundleIgnoreException(String bundleName, Locale locale)
Retrieves the bundle using the
ResourceBundle.getBundle(String, Locale) method,
returning null instead of throwing
MissingResourceException . |
String[] | getBundleNames() |
String | getDefaultBundleName() |
String | getDefaultCountry() |
String | getDefaultLanguage() |
Locale | getLocale(String header) |
String | getString(String key) |
String | getString(String key, Locale locale) |
String | getString(String bundleName, Locale locale, String key) |
protected String | getStringOrNull(ResourceBundle rb, String key)
Gets localized text from a bundle if it's there. |
void | initialize()
Called the first time the Service is used. |
protected void | initializeBundleNames() |
Throws: MissingResourceException Bundle not found.
Retrieves the bundle most closely matching first against the supplied inputs, then against the defaults.
Use case: some clients send a HTTP Accept-Language header with a value of only the language to use (i.e. "Accept-Language: en"), and neglect to include a country. When there is no bundle for the requested language, this method can be called to try the default country (checking internally to assure the requested criteria matches the default to avoid disconnects between language and country).
Since we're really just guessing at possible bundles to use,
we don't ever throw MissingResourceException
.
See Also: I18N
See Also: I18N
key
in the
ResourceBundle
referenced by
bundleName
, then formats that value for the
specified Locale
using args
.
Returns: Localized, formatted text identified by
key
.
Parameters: bundleName Name of bundle. languageHeader A String with the language header.
Returns: A localized ResourceBundle.
Parameters: bundleName Name of bundle (or null
for the
default bundle). locale The locale (or null
for the locale
indicated by the default language and country).
Returns: A localized ResourceBundle.
ResourceBundle.getBundle(String, Locale)
method,
returning null
instead of throwing
MissingResourceException
.See Also: getLocale
Throws: MissingResourceException Specified key cannot be matched.
See Also: I18N
null
(ignoring a possible
MissingResourceException
).