let get_locale t category =
let posix_lang = posix_getenv t category
in
let locale =
try
let lexbuf =
Lexing.from_string posix_lang
in
GettextLocale_parser.main
GettextLocale_lexer.token
lexbuf
with x ->
fail_or_continue t.failsafe
(LocalePosixUnparseable (posix_lang^" "^(Printexc.to_string x)))
(GettextLocale_types.create_locale posix_lang)
in
let locales =
match
(locale.GettextLocale_types.territory,locale.GettextLocale_types.modifier) with
Some territory, Some modifier ->
[
locale.GettextLocale_types.language^"_"^territory^"@"^modifier;
locale.GettextLocale_types.language^"_"^territory;
locale.GettextLocale_types.language
]
| None, Some modifier ->
[
locale.GettextLocale_types.language^"@"^modifier;
locale.GettextLocale_types.language
]
| Some territory, None ->
[
locale.GettextLocale_types.language^"_"^territory;
locale.GettextLocale_types.language
]
| None, None ->
[
locale.GettextLocale_types.language
]
in
let codeset =
match locale.GettextLocale_types.codeset with
Some codeset ->
codeset
| None ->
t.codeset
in
(locales,codeset)