diff --git a/Cargo.lock b/Cargo.lock index 23319cde..2f36218f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2997,6 +2997,7 @@ dependencies = [ "rust-i18n", "serde", "sevenz-rust", + "sys-locale", "tar", "tempfile", "toml 0.8.19", @@ -3616,6 +3617,15 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +[[package]] +name = "sys-locale" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e801cf239ecd6ccd71f03d270d67dd53d13e90aab208bf4b8fe4ad957ea949b0" +dependencies = [ + "libc", +] + [[package]] name = "system-configuration" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index dbe981b3..160b65f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,6 +48,7 @@ cfg-if = "1" env_proxy = "0.4.1" indexmap.workspace = true rust-i18n.workspace = true +sys-locale = "0.3.1" [target."cfg(windows)".dependencies] winreg = "0.52.0" diff --git a/installer/src-tauri/src/main.rs b/installer/src-tauri/src/main.rs index 21760268..734aa5d8 100644 --- a/installer/src-tauri/src/main.rs +++ b/installer/src-tauri/src/main.rs @@ -61,6 +61,7 @@ impl Mode { } fn main() -> Result<()> { + utils::use_current_locale(); Mode::detect().run() } diff --git a/src/bin/installer.rs b/src/bin/installer.rs index 9cd1dfda..96786ab1 100644 --- a/src/bin/installer.rs +++ b/src/bin/installer.rs @@ -33,5 +33,6 @@ impl Mode { } fn main() -> Result<()> { + utils::use_current_locale(); Mode::detect().run() } diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 89b088a0..fe08c0e7 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -75,3 +75,9 @@ pub fn lowercase_program_name() -> Option { pub fn to_string_lossy>(s: S) -> String { s.as_ref().to_string_lossy().to_string() } + +/// Allowing the i18n framework to use the current system locale. +pub fn use_current_locale() { + let locale = sys_locale::get_locale().unwrap_or_else(|| "en".to_string()); + rust_i18n::set_locale(&locale); +}