public interface LocalizationService
A service for obtaining ResourceBundle
s from the repository.
The ResourceBundle
s are located at /hippo:configuration/hippo:translations.
ResourceBundle
s are identified by a combination of a name and a Locale
.
ResourceBundle
resolution is implemented as follows. A Locale is interpreted to have
three levels of identity, which from least to most specific are: language, country, and variant.
These may not all be specified, only the least specific locale identifier, the language is mandatory.
When a ResourceBundle
is requested from the service, first an exact match is attempted, i.e.
a ResourceBundle
is searched that matches the full identity of the given Locale
.
If an exact match is not found a less exact match is attempted.
For example, if the ResourceBundle
for the Locale
th_TH_TH
is requested, first an exact match is attempted, if no such
ResourceBundle
exists one less specific ResourceBundle
is searched, i.e. th_TH
,
and if that also does not yield a result, the ResourceBundle
for the th
locale is looked up.
Finally, if still no ResourceBundle
is found, a ResourceBundle
with that name for the
DEFAULT_LOCALE
is returned if one exists.
In the same way, according to the same criteria of decreasing specificity of identity, ResourceBundle
s
are linked in a fallback hierarchy: If the ResourceBundle
matching the exact identity of th_TH_TH
does not yield a result for a specific ResourceBundle.getString(String)
, the implementation falls back on
a match higher up in the hierarchy: first the ResourceBundle
for th_TH
is attempted (if it exists)
all the way up to the default bundle.
Modifier and Type | Field and Description |
---|---|
static Locale |
DEFAULT_LOCALE
The default
Locale this service uses as fallback when the ResourceBundle
in the requested Locale is not available. |
static String |
TRANSLATIONS_PATH
The root path in the repository where
ResourceBundle s are stored. |
Modifier and Type | Method and Description |
---|---|
ResourceBundle |
getResourceBundle(String name,
Locale locale)
Get a
ResourceBundle from the repository by name and Locale . |
static final String TRANSLATIONS_PATH
ResourceBundle
s are stored.static final Locale DEFAULT_LOCALE
Locale
this service uses as fallback when the ResourceBundle
in the requested Locale is not available.ResourceBundle getResourceBundle(String name, Locale locale)
ResourceBundle
from the repository by name and Locale
.
The name of a resource bundle is path relative to the TRANSLATIONS_PATH
where the path elements are separated by periods (".") instead of forward slashes.
A Locale
object identifies the ResourceBundle
among the bundles identified by same path.
If the ResourceBundle
for the requested locale is not available the implementation tries to return
the ResourceBundle
for the default Locale
identified by the same name.name
- the name of the ResourceBundle
locale
- the locale of the ResourceBundle
ResourceBundle
identified by the name
and locale
, the DEFAULT_LOCALE
if the requested locale is not available or null
if no default ResourceBundle
with that name exists either.Copyright © 2007–2019 Hippo B.V. (http://www.onehippo.com). All rights reserved.