- java.lang.Object
-
- io.github.mmm.base.i18n.LocaleHelper
-
-
Field Summary
Fields Modifier and Type Field Description static char
SEPARATOR_DEFAULT
The default separator used forlocale-infixes
.static char
SEPARATOR_EXTENSION
The separator used forextension keys
.static char
SEPARATOR_FOR_LANGUAGE_TAG
The separator used forlanguage tag
.static char
SEPARATOR_SCRIPT
The separator used forscript
.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Locale
fromString(String locale)
Create aLocale
from a givenString
representation such asLocale.toString()
orLocale.forLanguageTag(String)
.static String
toInfix(Locale locale)
static String[]
toInfixes(Locale locale)
This method determines the infix-strings for localization lookup ordered from most specific to least specific (empty string representingLocale.ROOT
).
-
-
-
Field Detail
-
SEPARATOR_DEFAULT
public static final char SEPARATOR_DEFAULT
The default separator used forlocale-infixes
.- See Also:
- Constant Field Values
-
SEPARATOR_FOR_LANGUAGE_TAG
public static final char SEPARATOR_FOR_LANGUAGE_TAG
The separator used forlanguage tag
.- See Also:
- Constant Field Values
-
SEPARATOR_EXTENSION
public static final char SEPARATOR_EXTENSION
The separator used forextension keys
.- See Also:
- Constant Field Values
-
SEPARATOR_SCRIPT
public static final char SEPARATOR_SCRIPT
The separator used forscript
.- See Also:
- Constant Field Values
-
-
Method Detail
-
toInfix
public static String toInfix(Locale locale)
- Parameters:
locale
- is theLocale
.- Returns:
- the localization-infix in the form
[_
. Will be the emptylanguage
[_country
[_variant
]]]String
for theroot locale
. E.g. forLocale.GERMANY
this method will return "_de_DE".
-
toInfixes
public static String[] toInfixes(Locale locale)
This method determines the infix-strings for localization lookup ordered from most specific to least specific (empty string representingLocale.ROOT
). Each infix is defined as:[_
Please note that if a segment is empty but a following segment is present, multiple underscores ('_') will occur.language
[_country
[_variant
]]]
Examples:locale result Locale.GERMANY
{"_de_DE", "_de", ""}
new
Locale
("", "CM"){"__CM", ""}
new
Locale
("", "", "variant"){"___variant", ""}
- Parameters:
locale
- is theLocale
.- Returns:
- the localization-infixes ordered from most specific to least specific. The returned array will always contain the empty string as last entry.
-
fromString
public static Locale fromString(String locale)
Create aLocale
from a givenString
representation such asLocale.toString()
orLocale.forLanguageTag(String)
.- Parameters:
locale
- theString
representation of theLocale
. May be an fromLocale.toString()
,Locale.toLanguageTag()
ortoInfix(Locale)
.- Returns:
- the parsed
Locale
.
-
-