mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-30 21:16:52 -06:00
Merge pull request #309 from FeiLiuEM/i18n/zh-hans
i18n: add Simplified and Traditional Chinese (zh-hans, zh-hant) UI translation
This commit is contained in:
@@ -23,7 +23,13 @@ pub const PREFS_VERSION: u32 = 2;
|
||||
pub const PREFS_FILE: &str = "prefs.json";
|
||||
|
||||
/// Settings ▸ General ▸ Language: (label, `general.language` value).
|
||||
pub const LANGUAGES: &[(&str, &str)] = &[("Match System", "system"), ("English", "en"), ("日本語", "ja")];
|
||||
pub const LANGUAGES: &[(&str, &str)] = &[
|
||||
("Match System", "system"),
|
||||
("English", "en"),
|
||||
("日本語", "ja"),
|
||||
("简体中文", "zh-hans"),
|
||||
("繁體中文", "zh-hant"),
|
||||
];
|
||||
|
||||
/// Settings ▸ Startup & Repair ▸ Window Graphics: (label, `startup.windowGraphics` value).
|
||||
pub const WINDOW_GRAPHICS: &[(&str, &str)] = &[("Automatic", "auto"), ("OpenGL (compatibility)", "gl")];
|
||||
|
||||
@@ -514,6 +514,17 @@ fn interface_language_is_validated_persisted_and_backward_compatible() {
|
||||
assert_eq!(s.prefs.general.language, "ja");
|
||||
assert_eq!(store.read(PREFS_FILE).unwrap(), saved);
|
||||
}
|
||||
// zh-hans is registered alongside en and ja: it is accepted, persisted and read back.
|
||||
s.execute("prefs.set", json!({"key": "general.language", "value": "zh-hans"})).unwrap();
|
||||
let mut zh = Session { config: Some(store.clone()), ..Default::default() };
|
||||
zh.load_settings();
|
||||
assert_eq!(zh.prefs.general.language, "zh-hans");
|
||||
// zh-hant is the same: another language of the registered set, not an error.
|
||||
s.execute("prefs.set", json!({"key": "general.language", "value": "zh-hant"})).unwrap();
|
||||
let mut zh_hant = Session { config: Some(store.clone()), ..Default::default() };
|
||||
zh_hant.load_settings();
|
||||
assert_eq!(zh_hant.prefs.general.language, "zh-hant");
|
||||
s.execute("prefs.set", json!({"key": "general.language", "value": "ja"})).unwrap();
|
||||
let mut reloaded = Session { config: Some(store), ..Default::default() };
|
||||
reloaded.load_settings();
|
||||
assert_eq!(reloaded.prefs.general.language, "ja");
|
||||
|
||||
Reference in New Issue
Block a user