mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
This commit is contained in:
28
src/lang.rs
28
src/lang.rs
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user