File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -74,10 +74,7 @@ impl SimpleBackend {
74
74
. map ( |( k, v) | ( ( * k) . into ( ) , ( * v) . into ( ) ) )
75
75
. collect :: < HashMap < _ , _ > > ( ) ;
76
76
77
- let trs = self
78
- . translations
79
- . entry ( locale. into ( ) )
80
- . or_insert ( HashMap :: new ( ) ) ;
77
+ let trs = self . translations . entry ( locale. into ( ) ) . or_default ( ) ;
81
78
trs. extend ( data) ;
82
79
}
83
80
}
Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ rust_i18n::i18n!(
33
33
34
34
#[ cfg( test) ]
35
35
mod tests {
36
+ use std:: { thread, time:: Duration } ;
37
+
36
38
use rust_i18n:: t;
37
39
use rust_i18n_support:: load_locales;
38
40
@@ -315,4 +317,12 @@ mod tests {
315
317
"This is missing key fallbacked to en."
316
318
) ;
317
319
}
320
+
321
+ #[ test]
322
+ fn test_set_locale ( ) {
323
+ rust_i18n:: set_locale ( "zh-CN" ) ;
324
+ for _ in 0 ..5 {
325
+ assert_eq ! ( t!( "hello" ) , "Bar - 你好世界!" ) ;
326
+ }
327
+ }
318
328
}
You can’t perform that action at this time.
0 commit comments