Commit 19e9145 1 parent 07e4c65 commit 19e9145 Copy full SHA for 19e9145
File tree 2 files changed +9
-3
lines changed
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -324,6 +324,8 @@ fn generate_code(
324
324
quote ! {
325
325
use rust_i18n:: { BackendExt , CowStr , MinifyKey } ;
326
326
use std:: borrow:: Cow ;
327
+ use std:: sync:: Mutex ;
328
+ use rust_i18n:: once_cell:: sync:: Lazy ;
327
329
328
330
/// I18n backend instance
329
331
///
@@ -334,11 +336,17 @@ fn generate_code(
334
336
#( #all_translations) *
335
337
#extend_code
336
338
337
- #default_locale
339
+ if * _RUST_I18N_INITIALIZED_DEFAULT_LOCALE. lock( ) . unwrap( ) == false {
340
+ * _RUST_I18N_INITIALIZED_DEFAULT_LOCALE. lock( ) . unwrap( ) = true ;
341
+ #default_locale
342
+ }
338
343
339
344
Box :: new( backend)
340
345
} ) ;
341
346
347
+ /// To mark the default locale has been initialized
348
+ static _RUST_I18N_INITIALIZED_DEFAULT_LOCALE: Lazy <Mutex <bool >> = Lazy :: new( || Mutex :: new( false ) ) ;
349
+
342
350
static _RUST_I18N_FALLBACK_LOCALE: Option <& [ & ' static str ] > = #fallback;
343
351
static _RUST_I18N_MINIFY_KEY: bool = #minify_key;
344
352
static _RUST_I18N_MINIFY_KEY_LEN: usize = #minify_key_len;
Original file line number Diff line number Diff line change @@ -33,8 +33,6 @@ rust_i18n::i18n!(
33
33
34
34
#[ cfg( test) ]
35
35
mod tests {
36
- use std:: { thread, time:: Duration } ;
37
-
38
36
use rust_i18n:: t;
39
37
use rust_i18n_support:: load_locales;
40
38
You can’t perform that action at this time.
0 commit comments