rustdesk
2022-06-05 18:02:54 +08:00
parent 5007ac208c
commit 463fc2f0c0
3 changed files with 20 additions and 18 deletions

View File

@@ -1,17 +1,18 @@
use std::ops::Deref;
mod cn;
mod en;
mod fr;
mod it;
mod tw;
mod de;
mod ru;
mod eo;
mod ptbr;
mod id;
mod tr;
mod cs;
mod da;
mod de;
mod en;
mod eo;
mod fr;
mod id;
mod it;
mod ptbr;
mod ru;
mod tr;
mod tw;
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn translate(name: String) -> String {
@@ -23,14 +24,14 @@ pub fn translate_locale(name: String, locale: &str) -> String {
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") && (locale.ends_with("CN") || locale.ends_with("SG") || locale.ends_with("Hans")) {
lang = "cn".to_owned();
if locale.starts_with("zh") {
lang = (if locale.contains("TW") { "tw" } else { "cn" }).to_owned();
}
}
if lang.is_empty() {
lang = locale
.split("-")
.last()
.next()
.map(|x| x.split("_").last().unwrap_or_default())
.unwrap_or_default()
.to_owned();
@@ -50,6 +51,7 @@ pub fn translate_locale(name: String, locale: &str) -> String {
"pt" => ptbr::T.deref(),
"tr" => tr::T.deref(),
"cs" => cs::T.deref(),
"da" => da::T.deref(),
_ => en::T.deref(),
};
if let Some(v) = m.get(&name as &str) {