let posix_getenv t category =
(* http://www.gnu.org/software/gettext/manual/html_mono/gettext.html#SEC155
In the function dcgettext at every call the current setting of the
highest priority environment variable is determined and used.
Highest priority means here the following list with decreasing priority:
1. LANGUAGE
2. LC_ALL
3. LC_xxx, according to selected locale
4. LANG
*)
match t.language with
Some str ->
str
| None ->
let best_env =
List.find (
fun s ->
try
ignore(Sys.getenv s);
true
with Not_found ->
false
) [
"LANGUAGE" ;
string_of_category LC_ALL ;
string_of_category category;
"LANG" ]
in
Sys.getenv best_env