1use glossa::sys::new_once_lock;
2
3fn get_env(s: &str) -> Option<String> {
4 std::env::var(s)
5 .ok()
6 .filter(|x| !x.trim_ascii().is_empty())
7}
8
9pub fn static_glossa_cfg_dir() -> Option<&'static str> {
12 new_once_lock!(V: Option<String>);
13 V.get_or_init(|| get_env("GLOSSA_CFG_DIR"))
14 .as_deref()
15}
16
17pub fn static_glossa_l10n_dir() -> Option<&'static str> {
19 new_once_lock!(V: Option<String>);
20 V.get_or_init(|| get_env("GLOSSA_L10N_DIR"))
21 .as_deref()
22}
23
24pub fn static_glossa_lang() -> Option<&'static str> {
26 new_once_lock!(L: Option<String>);
27
28 L.get_or_init(|| get_env("GLOSSA_LANG"))
29 .as_deref()
30}
31
32pub(crate) fn format_glossa_env() -> &'static str {
33 let (lang, l10n_dir, cfg_dir) = (
34 static_glossa_lang(),
35 static_glossa_l10n_dir(),
36 static_glossa_cfg_dir(),
37 );
38
39 log::info!(
40 "env:
41 GLOSSA_LANG: {lang:?}
42 GLOSSA_L10N_DIR: {l10n_dir:?}
43 GLOSSA_CFG_DIR: {cfg_dir:?}
44 GLOSSA_LOG: {log_lv:?}
45 ",
46 log_lv = get_env("GLOSSA_LOG")
47 );
48 ""
49}