public class PreferredLocales extends Object
ResourceBundle
s.
ResourceBundle
s are found by iterating over the preferred locales
and returning the first resource bundle for which a non-ROOT locale is
available, that is not listed later in the list, or the ROOT locale if no
better match is found.
For example, given available locales of en
and fr
:
fr-FR, en
, resource bundle for locale
fr
is returned.
fr-FR, en, fr
, resource bundle for locale
en
is returned (fr
is listed lower than en
).
de
, resource bundle for the ROOT locale
is returned.
MyBundle.properties
) is en-US
. If this is not the case for an
application, it can be changed by setting the
org.forgerock.defaultBundleLocale
system property.Constructor and Description |
---|
PreferredLocales()
Create a new, empty preference of locales.
|
PreferredLocales(List<Locale> locales)
Create a new preference of locales by copying the provided locales list.
|
Modifier and Type | Method and Description |
---|---|
ResourceBundle |
getBundleInPreferredLocale(String bundleName,
ClassLoader classLoader)
Get a
ResourceBundle using the preferred locale list and using the provided
ClassLoader . |
List<Locale> |
getLocales()
The ordered list of preferred locales.
|
Locale |
getPreferredLocale()
The preferred locale, i.e. the head of the preferred locales list.
|
public PreferredLocales(List<Locale> locales)
locales
- The list of locales that are preferred, with the first item the most preferred.public PreferredLocales()
public Locale getPreferredLocale()
public List<Locale> getLocales()
public ResourceBundle getBundleInPreferredLocale(String bundleName, ClassLoader classLoader)
ResourceBundle
using the preferred locale list and using the provided
ClassLoader
.bundleName
- The of the bundle to load.classLoader
- The ClassLoader
to use to load the bundle.Copyright © 2025 Open Identity Platform Community. All rights reserved.