This commit is contained in:
rustdesk 2024-03-06 17:38:33 +08:00
parent fccdc8ca1f
commit f3686b23c7

View File

@ -83,16 +83,17 @@ pub const LANGS: &[(&str, &str)] = &[
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn translate(name: String) -> String {
let locale = sys_locale::get_locale().unwrap_or_default().to_lowercase();
let locale = sys_locale::get_locale().unwrap_or_default();
translate_locale(name, &locale)
}
pub fn translate_locale(name: String, locale: &str) -> String {
let locale = locale.to_lowercase();
let mut lang = hbb_common::config::LocalConfig::get_option("lang").to_lowercase();
if lang.is_empty() {
// zh_CN on Linux, zh-Hans-CN on mac, zh_CN_#Hans on Android
if locale.starts_with("zh") {
lang = (if locale.contains("TW") {
lang = (if locale.contains("tw") {
"zh-tw"
} else {
"zh-cn"