From c9d557946045fa88ca09025900f987e687852c62 Mon Sep 17 00:00:00 2001 From: yk0n9 Date: Tue, 20 Aug 2024 17:59:00 +0800 Subject: [PATCH] fix lazy init always en Co-authored-by: yk0n9 Co-authored-by: KKRainbow --- crates/macro/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/macro/src/lib.rs b/crates/macro/src/lib.rs index 49470cf..c9148ea 100644 --- a/crates/macro/src/lib.rs +++ b/crates/macro/src/lib.rs @@ -292,7 +292,12 @@ fn generate_code( let default_locale = if let Some(default_locale) = args.default_locale { quote! { - rust_i18n::set_locale(#default_locale); + use std::ops::Deref; + if #default_locale != rust_i18n::locale().deref() { + rust_i18n::set_locale(rust_i18n::locale().deref()); + } else { + rust_i18n::set_locale(#default_locale); + } } } else { quote! {}