macos local setting

This commit is contained in:
Dongdong Zhou 2021-10-18 22:57:28 +01:00
parent 87f8f6bce7
commit 3aa7979d1c
3 changed files with 25 additions and 1 deletions

16
Cargo.lock generated
View File

@ -498,7 +498,7 @@ dependencies = [
"clicolors-control",
"lazy_static 1.4.0",
"libc",
"parking_lot 0.6.4",
"parking_lot 0.11.2",
"regex",
"termios",
"unicode-width",
@ -1999,6 +1999,7 @@ dependencies = [
"home",
"jsonrpc-lite",
"lapce-rpc",
"locale_config",
"lsp-types",
"mio 0.6.23",
"notify",
@ -2140,6 +2141,19 @@ version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
[[package]]
name = "locale_config"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d2c35b16f4483f6c26f0e4e9550717a2f6575bcd6f12a53ff0c490a94a6934"
dependencies = [
"lazy_static 1.4.0",
"objc",
"objc-foundation",
"regex",
"winapi 0.3.9",
]
[[package]]
name = "lock_api"
version = "0.1.5"

View File

@ -5,6 +5,7 @@ authors = ["Dongdong Zhou <dzhou121@gmail.com>"]
edition = "2018"
[dependencies]
locale_config = "0.3.0"
base64 = "0.13.0"
alacritty_terminal = "0.15.0"
mio = "0.6.20"

View File

@ -75,6 +75,10 @@ pub fn new(
args: vec!["-l".to_string()],
});
setup_env(&config);
#[cfg(target_os = "macos")]
set_locale_environment();
let size =
SizeInfo::new(width as f32, height as f32, 1.0, 1.0, 0.0, 0.0, true);
let mut pty = alacritty_terminal::tty::new(&config, &size, None);
@ -308,3 +312,8 @@ fn set_current(&mut self, new: Option<Writing>) {
self.writing = new;
}
}
fn set_locale_environment() {
let locale = locale_config::Locale::global_default().to_string().replace("-", "_");
std::env::set_var("LC_ALL", locale + ".UTF-8");
}