mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-11-05 16:38:17 +00:00
fix(lang): pick Traditional Chinese for Hong Kong and Macao system locales (#16671)
* fix(lang): pick Traditional Chinese for Hong Kong and Macao system locales With no language chosen in Settings, resolve_lang picks zh-tw only when the system locale contains tw. Hong Kong and Macao locales (zh_HK, zh-Hant-HK, zh_HK_#Hant, zh_MO) and a bare zh-Hant got Simplified Chinese, although they write Traditional Chinese. Pick zh-tw for them too, unless the locale names the Hans script. * test(lang): cover a bare zh-Hant locale
This commit is contained in:
1 parent
25d2742273
commit
f7b0af78cb
1 file changed
+15
+15
@@ -143,6 +143,10 @@ fn resolve_lang(saved_lang: &str, locale: &str, cjk_fallback: bool) -> String {
|
|||||||
"zh-cn"
|
"zh-cn"
|
||||||
})
|
})
|
||||||
.to_owned();
|
.to_owned();
|
||||||
|
// Hong Kong, Macao and the Hant script use Traditional Chinese.
|
||||||
|
if !locale.contains("hans") && ["hk", "mo", "hant"].iter().any(|x| locale.contains(x)) {
|
||||||
|
lang = "zh-tw".to_owned();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if lang.is_empty() {
|
if lang.is_empty() {
|
||||||
@@ -381,4 +385,15 @@ mod test {
|
|||||||
assert_eq!(f("", "ka_GE.UTF-8", false), "ge");
|
assert_eq!(f("", "ka_GE.UTF-8", false), "ge");
|
||||||
assert_eq!(f("", "ka-GE", false), "ge");
|
assert_eq!(f("", "ka-GE", false), "ge");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_resolve_lang_detects_traditional_chinese_for_hong_kong_and_macao() {
|
||||||
|
use super::resolve_lang as f;
|
||||||
|
|
||||||
|
assert_eq!(f("", "zh_HK.UTF-8", false), "zh-tw");
|
||||||
|
assert_eq!(f("", "zh-Hant-HK", false), "zh-tw");
|
||||||
|
assert_eq!(f("", "zh-Hant", false), "zh-tw");
|
||||||
|
assert_eq!(f("", "zh_MO", false), "zh-tw");
|
||||||
|
assert_eq!(f("", "zh-Hans-HK", false), "zh-cn");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user