Skip to content

Commit 07e4c65

Browse files
committed
Add test to covert #87
1 parent 5d4b561 commit 07e4c65

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

crates/support/src/backend.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ impl SimpleBackend {
7474
.map(|(k, v)| ((*k).into(), (*v).into()))
7575
.collect::<HashMap<_, _>>();
7676

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();
8178
trs.extend(data);
8279
}
8380
}

tests/integration_tests.rs

+10
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ rust_i18n::i18n!(
3333

3434
#[cfg(test)]
3535
mod tests {
36+
use std::{thread, time::Duration};
37+
3638
use rust_i18n::t;
3739
use rust_i18n_support::load_locales;
3840

@@ -315,4 +317,12 @@ mod tests {
315317
"This is missing key fallbacked to en."
316318
);
317319
}
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+
}
318328
}

0 commit comments

Comments
 (0)