java.lang.Object
io.github.mmm.base.i18n.LocaleHelper
Simple helper for
Locale specific stuff.- Since:
- 1.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charThe default separator used forlocale-infixes.static final charThe separator used forextension keys.static final charThe separator used forlanguage tag.static final charThe separator used forscript. -
Method Summary
Modifier and TypeMethodDescriptionstatic LocalefromString(String locale) Create aLocalefrom a givenStringrepresentation such asLocale.toString()orLocale.forLanguageTag(String).static Stringstatic String[]This method determines the infix-strings for localization lookup ordered from most specific to least specific (empty string representingLocale.ROOT).
-
Field Details
-
SEPARATOR_DEFAULT
public static final char SEPARATOR_DEFAULTThe default separator used forlocale-infixes.- See Also:
-
SEPARATOR_FOR_LANGUAGE_TAG
public static final char SEPARATOR_FOR_LANGUAGE_TAGThe separator used forlanguage tag.- See Also:
-
SEPARATOR_EXTENSION
public static final char SEPARATOR_EXTENSIONThe separator used forextension keys.- See Also:
-
SEPARATOR_SCRIPT
public static final char SEPARATOR_SCRIPTThe separator used forscript.- See Also:
-
-
Method Details
-
toInfix
- 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
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
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.
-