Support LC_ALL

This commit is contained in:
Sasha Koshka 2024-10-04 23:57:12 -04:00
parent 1da2f21763
commit 3e3c794a1e

View File

@ -39,7 +39,10 @@ export fn get_time() locale = get_locale("LC_TIME");
export fn get_messages() locale = get_locale("LC_MESSAGES"); export fn get_messages() locale = get_locale("LC_MESSAGES");
fn get_locale(var: str) locale = fn get_locale(var: str) locale =
match (get_locale_no_fallback(var)) { match (get_locale_no_fallback("LC_ALL")) {
case let local: locale => yield local;
case =>
yield match (get_locale_no_fallback(var)) {
case let local: locale => yield local; case let local: locale => yield local;
case => case =>
yield match (get_locale_no_fallback("LANG")) { yield match (get_locale_no_fallback("LANG")) {
@ -47,6 +50,7 @@ fn get_locale(var: str) locale =
case => yield c; case => yield c;
}; };
}; };
};
fn get_locale_no_fallback(var: str) (locale | errors::invalid) = fn get_locale_no_fallback(var: str) (locale | errors::invalid) =
match (get_env_locale(var)) { match (get_env_locale(var)) {