mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-06-22 16:24:52 +03:00
Compare commits
2 Commits
cjk_armlin
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b40c61d8e | ||
|
|
dcc64cdeae |
@@ -113,11 +113,11 @@ pub enum MouseButton {
|
|||||||
|
|
||||||
/// Scroll up button
|
/// Scroll up button
|
||||||
ScrollUp,
|
ScrollUp,
|
||||||
/// Left right button
|
/// Scroll down button
|
||||||
ScrollDown,
|
ScrollDown,
|
||||||
/// Left right button
|
/// Scroll left button
|
||||||
ScrollLeft,
|
ScrollLeft,
|
||||||
/// Left right button
|
/// Scroll right button
|
||||||
ScrollRight,
|
ScrollRight,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ impl KeyboardControllable for Enigo {
|
|||||||
// Windows uses uft-16 encoding. We need to check
|
// Windows uses uft-16 encoding. We need to check
|
||||||
// for variable length characters. As such some
|
// for variable length characters. As such some
|
||||||
// characters can be 32 bit long and those are
|
// characters can be 32 bit long and those are
|
||||||
// encoded in such called hight and low surrogates
|
// encoded in so-called high and low surrogates
|
||||||
// each 16 bit wide that needs to be send after
|
// each 16 bit wide that needs to be send after
|
||||||
// another to the SendInput function without
|
// another to the SendInput function without
|
||||||
// being interrupted by "keyup"
|
// being interrupted by "keyup"
|
||||||
|
|||||||
Submodule libs/hbb_common updated: 387603f47c...f857bbd3bc
@@ -45,7 +45,7 @@ pre_start()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# When loging out from the interactive shell, the execution sequence is:
|
# When logging out from the interactive shell, the execution sequence is:
|
||||||
#
|
#
|
||||||
# IF ~/.bash_logout exists THEN
|
# IF ~/.bash_logout exists THEN
|
||||||
# execute ~/.bash_logout
|
# execute ~/.bash_logout
|
||||||
|
|||||||
74
src/lang.rs
74
src/lang.rs
@@ -103,15 +103,29 @@ pub const LANGS: &[(&str, &str)] = &[
|
|||||||
("gu", "ગુજરાતી"),
|
("gu", "ગુજરાતી"),
|
||||||
];
|
];
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
pub(crate) fn cjk_ui_unavailable() -> bool {
|
||||||
pub fn translate(name: String) -> String {
|
cfg!(all(
|
||||||
let locale = sys_locale::get_locale().unwrap_or_default();
|
target_os = "linux",
|
||||||
translate_locale(name, &locale)
|
target_arch = "aarch64",
|
||||||
|
feature = "flutter"
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn translate_locale(name: String, locale: &str) -> String {
|
pub(crate) fn is_cjk_lang(lang_or_locale: &str) -> bool {
|
||||||
|
let lang = lang_or_locale
|
||||||
|
.split(|c| c == '-' || c == '_')
|
||||||
|
.next()
|
||||||
|
.unwrap_or_default()
|
||||||
|
.to_lowercase();
|
||||||
|
matches!(lang.as_str(), "zh" | "ja" | "ko")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn resolve_lang(saved_lang: &str, locale: &str, cjk_fallback: bool) -> String {
|
||||||
let locale = locale.to_lowercase();
|
let locale = locale.to_lowercase();
|
||||||
let mut lang = hbb_common::config::LocalConfig::get_option("lang").to_lowercase();
|
let mut lang = saved_lang.to_lowercase();
|
||||||
|
if cjk_fallback && is_cjk_lang(&lang) {
|
||||||
|
return "en".to_owned();
|
||||||
|
}
|
||||||
if lang.is_empty() {
|
if lang.is_empty() {
|
||||||
// zh_CN on Linux, zh-Hans-CN on mac, zh_CN_#Hans on Android
|
// zh_CN on Linux, zh-Hans-CN on mac, zh_CN_#Hans on Android
|
||||||
if locale.starts_with("zh") {
|
if locale.starts_with("zh") {
|
||||||
@@ -131,7 +145,25 @@ pub fn translate_locale(name: String, locale: &str) -> String {
|
|||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.to_owned();
|
.to_owned();
|
||||||
}
|
}
|
||||||
let lang = lang.to_lowercase();
|
if cjk_fallback && is_cjk_lang(&lang) {
|
||||||
|
"en".to_owned()
|
||||||
|
} else {
|
||||||
|
lang
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
|
pub fn translate(name: String) -> String {
|
||||||
|
let locale = sys_locale::get_locale().unwrap_or_default();
|
||||||
|
translate_locale(name, &locale)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn translate_locale(name: String, locale: &str) -> String {
|
||||||
|
let lang = resolve_lang(
|
||||||
|
&hbb_common::config::LocalConfig::get_option("lang"),
|
||||||
|
locale,
|
||||||
|
cjk_ui_unavailable(),
|
||||||
|
);
|
||||||
let m = match lang.as_str() {
|
let m = match lang.as_str() {
|
||||||
"fr" => fr::T.deref(),
|
"fr" => fr::T.deref(),
|
||||||
"zh-cn" => cn::T.deref(),
|
"zh-cn" => cn::T.deref(),
|
||||||
@@ -275,4 +307,32 @@ mod test {
|
|||||||
("{} times {4} makes {8}".to_string(), Some("2".to_string()))
|
("{} times {4} makes {8}".to_string(), Some("2".to_string()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_resolve_lang_forces_english_for_saved_cjk_when_target_disables_cjk() {
|
||||||
|
use super::resolve_lang as f;
|
||||||
|
|
||||||
|
assert_eq!(f("zh-cn", "en-US", true), "en");
|
||||||
|
assert_eq!(f("zh-tw", "en-US", true), "en");
|
||||||
|
assert_eq!(f("ja", "en-US", true), "en");
|
||||||
|
assert_eq!(f("ko", "en-US", true), "en");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_resolve_lang_forces_english_for_cjk_locale_when_target_disables_cjk() {
|
||||||
|
use super::resolve_lang as f;
|
||||||
|
|
||||||
|
assert_eq!(f("", "zh_CN", true), "en");
|
||||||
|
assert_eq!(f("", "ja-JP", true), "en");
|
||||||
|
assert_eq!(f("", "ko_KR", true), "en");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_resolve_lang_preserves_cjk_when_target_allows_cjk() {
|
||||||
|
use super::resolve_lang as f;
|
||||||
|
|
||||||
|
assert_eq!(f("zh-cn", "en-US", false), "zh-cn");
|
||||||
|
assert_eq!(f("", "zh_TW", false), "zh-tw");
|
||||||
|
assert_eq!(f("", "ja-JP", false), "ja");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/// Url handler based on dbus
|
/// Url handler based on dbus
|
||||||
///
|
///
|
||||||
/// Note:
|
/// Note:
|
||||||
/// On linux, we use dbus to communicate multiple rustdesk process.
|
/// On linux, we use dbus to communicate between multiple rustdesk processes.
|
||||||
/// [Flutter]: handle uni links for linux
|
/// [Flutter]: handle uni links for linux
|
||||||
use dbus::blocking::Connection;
|
use dbus::blocking::Connection;
|
||||||
use dbus_crossroads::{Crossroads, IfaceBuilder};
|
use dbus_crossroads::{Crossroads, IfaceBuilder};
|
||||||
|
|||||||
@@ -902,8 +902,10 @@ pub fn get_async_job_status() -> String {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_langs() -> String {
|
pub fn get_langs() -> String {
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
let hide_cjk = crate::lang::cjk_ui_unavailable();
|
||||||
let mut x: Vec<(&str, String)> = crate::lang::LANGS
|
let mut x: Vec<(&str, String)> = crate::lang::LANGS
|
||||||
.iter()
|
.iter()
|
||||||
|
.filter(|a| !hide_cjk || !crate::lang::is_cjk_lang(a.0))
|
||||||
.map(|a| (a.0, format!("{} ({})", a.1, a.0)))
|
.map(|a| (a.0, format!("{} ({})", a.1, a.0)))
|
||||||
.collect();
|
.collect();
|
||||||
x.sort_by(|a, b| a.0.cmp(b.0));
|
x.sort_by(|a, b| a.0.cmp(b.0));
|
||||||
|
|||||||
Reference in New Issue
Block a user