public final class Locales extends Static
Locale
instances. While this class is documented as
providing static methods, a few methods are actually non-static. Those methods need to be
invoked on the ALL
or SIS
instance in order to specify the scope.
Examples:
Locales[] lc1 = Locales.ALL.getAvailableLanguages(); // All languages installed on the JavaVM. Locales[] lc2 = Locales.SIS.getAvailableLanguages(); // Only the languages known to Apache SIS.
Defined in the sis-utility
module
Modifier and Type | Field and Description |
---|---|
static Locales |
ALL
All locales available on the JavaVM.
|
static Locales |
SIS
Only locales available in the Apache SIS library.
|
Modifier and Type | Method and Description |
---|---|
Locale[] |
getAvailableLanguages()
|
Locale[] |
getAvailableLocales()
|
static Locale |
parse(String code)
Parses the given language code, optionally followed by country code and variant.
|
static Locale |
parse(String code,
int fromIndex)
Parses the given language code and optional complements (country, variant), starting at the given index.
|
static Locale |
unique(Locale locale)
Returns a unique instance of the given locale, if one is available.
|
public static final Locales ALL
public static final Locales SIS
public Locale[] getAvailableLanguages()
ALL
) or to the Apache SIS library
(SIS
). In the later case, this method returns only the languages for which
localized resources are provided in the org.apache.sis.util.resources
package.public Locale[] getAvailableLocales()
ALL
) or to the Apache SIS library
(SIS
). In the later case, this method returns only the locales for which
localized resources are provided in the org.apache.sis.util.resources
package.public static Locale parse(String code)
'_'
character and the
country code (again either as 2 or 3 letters), optionally followed by '_'
and the variant.
This method can be used when the caller wants the same Locale
constants no matter if the language
and country codes use 2 or 3 letters. This method tries to convert 3-letters codes to 2-letters code on a
best effort basis.
code
- The language code, optionally followed by country code and variant.null
).RuntimeException
- If the given code is not valid (IllformedLocaleException
on the JDK7 branch).Locale.forLanguageTag(String)
public static Locale parse(String code, int fromIndex)
fromIndex
are ignored. Characters from fromIndex
to the end of the
string are parsed as documented in the parse(String)
method. In particular, this method tries to
convert 3-letters codes to 2-letters code on a best effort basis.
"remarks"
property by values associated to the
"remarks_en"
and "remarks_fr"
keys, for English and French locales respectively.code
- The language code, which may be followed by country code.fromIndex
- Index of the first character to parse.null
).RuntimeException
- If the given code is not valid (IllformedLocaleException
on the JDK7 branch).Locale.forLanguageTag(String)
,
Types.toInternationalString(Map, String)
Copyright © 2010–2015 The Apache Software Foundation. All rights reserved.