diff --git a/src/env_dispatch.rs b/src/env_dispatch.rs index e9bfd550c190..8edb25829174 100644 --- a/src/env_dispatch.rs +++ b/src/env_dispatch.rs @@ -800,6 +800,7 @@ fn init_locale(vars: &EnvStack) { _nl_msg_cat_cntr += 1; } } + crate::wutil::gettext::wgettext_clear_cache(); } } diff --git a/src/wutil/gettext.rs b/src/wutil/gettext.rs index b537ee42fac5..70c2158683fc 100644 --- a/src/wutil/gettext.rs +++ b/src/wutil/gettext.rs @@ -64,6 +64,13 @@ enum MaybeStatic<'a> { Local(&'a wstr), } +static WGETTEXT_MAP: Lazy>> = + Lazy::new(|| Mutex::new(HashMap::new())); + +pub fn wgettext_clear_cache() { + WGETTEXT_MAP.lock().unwrap().clear(); +} + /// Implementation detail for wgettext!. /// Wide character wrapper around the gettext function. For historic reasons, unlike the real /// gettext function, wgettext takes care of setting the correct domain, etc. using the textdomain @@ -86,8 +93,6 @@ fn wgettext_impl(text: MaybeStatic) -> &'static wstr { ); // Note that because entries are immortal, we simply leak non-static keys, and all values. - static WGETTEXT_MAP: Lazy>> = - Lazy::new(|| Mutex::new(HashMap::new())); let mut wmap = WGETTEXT_MAP.lock().unwrap(); let res = match wmap.get(key) { Some(v) => *v,