use lang_id::{LangID, sys_locale};
pub use testutils::new_once_lock;
pub fn retrieve_locale() -> LangID {
match () {
#[cfg(not(target_os = "macos"))]
() => sys_locale::retrieve_sys_or_env_lang(),
#[cfg(target_os = "macos")]
() => sys_locale::retrieve_env_lang_or_sys_locale(),
}
}
pub fn get_static_locale() -> &'static LangID {
new_once_lock!(LANG: LangID);
LANG.get_or_init(retrieve_locale)
}
#[cfg(test)]
mod tests {
use testutils::dbg_ref;
use super::*;
use crate::{LocaleContext, fallback::dbg_shared::init_logger};
#[ignore]
#[test]
fn test_get_or_init_posix_language_chain() {
init_logger(true);
dbg_ref!(get_static_locale());
let all_locales = {
use lang_id::consts::*;
[
lang_id_en(),
lang_id_zh(),
lang_id_ar(),
lang_id_de(),
lang_id_ru(),
lang_id_es_419(),
]
};
let ctx = LocaleContext::default().with_all_locales(all_locales);
let chain = ctx.get_or_try_init_chain();
dbg!(chain);
}
}