Translates a Locale String into a Locale, e.g....
"_en", "en", "en_", "en__", "_en__", "en_US", "en__US", "en_POSIX",
"en__POSIX", "en___POSIX", "en_US_POSIX", "en__US__POSIX", "US", "US_",
"_US", "_US_", "US_POSIX", "US__POSIX", "_US_POSIX", "_US__POSIX", "_POSIX",
"__POSIX"
Matches any Locale.toString() output plus more using the following regular
expression...
^[\s_]*?(?:_?([a-z]{2})_?)?(?:_?(?:([A-Z]{2})_?)?(?:_+?(\S+?))?)?\s*?$
--OR--
^[\s_]*?(?:_?({language}[a-z]{2})_?)?(?:_?(?:({country}[A-Z]{2})_?)?(?:_+?({variant}\S+?))?)?\s*?$
Preceding and trailing whitespace is ignored. Single preceding
underscores, connected or not to locale text, are ignored (though at least
one is required to define a stand-alone variant). Two preceding contiguous
underscores define a variant when either alone or connected to language
or country locale text (or variant, obviously). Trailing underscores
connected to the locale text are ignored unless part of the variant:
three contiguous underscores trailing language, two contiguous underscores
trailing country, or any trailing variant, e.g., ...
- " _ _ _ " --> match, but empty locale which will be ignored
- " _ _ __ " --> variant: "_"
- " _ _ _en__ _ " --> no match
- " _ _ _en__ " --> language: "en"
- " _ _ _en___ " --> language: "en", variant: "_"
- " _ _ _en___POSIX " --> language: "en", variant: "POSIX"
- " _ _ _en____POSIX " --> language: "en", variant: "_POSIX"
- " _ _ __en_ " --> variant: "en_"
- " _ _ _US_ _ " --> no match
- " _ _ _US_ " --> country: "US"
- " _ _ _US__ " --> country: "US", variant: "_"
- " _ _ _US__POSIX " --> country: "US", variant: "POSIX"
- " _ _ _US___POSIX " --> country: "US", variant: "_POSIX"
- " _ _ __US_ " --> variant: "US_"
- " _ _ POSIX_ " --> no match
- " _ _ _POSIX_ _ " --> no match
- " _ _ _POSIX_ " --> variant: "POSIX_"
- " _ _ __POSIX_ " --> variant: "POSIX_"
- " _ _ ___POSIX_ " --> variant: "_POSIX_"
- Parameters:
localeStr
- a String representing a Locale- Returns:
- the Locale corresponding to the provided localeStr or null if the
localeStr is null or doesn't match any Locale parts