- java.lang.Object
-
- io.github.mmm.base.i18n.LocaleHelper
-
-
Field Summary
Fields Modifier and Type Field Description static charSEPARATOR_DEFAULTThe default separator used forlocale-infixes.static charSEPARATOR_EXTENSIONThe separator used forextension keys.static charSEPARATOR_FOR_LANGUAGE_TAGThe separator used forlanguage tag.static charSEPARATOR_SCRIPTThe separator used forscript.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static LocalefromString(String locale)Create aLocalefrom a givenStringrepresentation such asLocale.toString()orLocale.forLanguageTag(String).static StringtoInfix(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]]]Stringfor theroot locale. E.g. forLocale.GERMANYthis 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", ""}newLocale("", "CM"){"__CM", ""}newLocale("", "", "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 aLocalefrom a givenStringrepresentation such asLocale.toString()orLocale.forLanguageTag(String).- Parameters:
locale- theStringrepresentation of theLocale. May be an fromLocale.toString(),Locale.toLanguageTag()ortoInfix(Locale).- Returns:
- the parsed
Locale.
-
-