Skip to content

Commit

Permalink
Merge pull request #142 from J-ZhengLi/dev-zhengli
Browse files Browse the repository at this point in the history
add system locale detection
  • Loading branch information
J-ZhengLi authored Oct 12, 2024
2 parents a302bc6 + 6d84706 commit 762cfe6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions installer/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ impl Mode {
}

fn main() -> Result<()> {
utils::use_current_locale();
Mode::detect().run()
}

Expand Down
1 change: 1 addition & 0 deletions src/bin/installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ impl Mode {
}

fn main() -> Result<()> {
utils::use_current_locale();
Mode::detect().run()
}
6 changes: 6 additions & 0 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ pub fn lowercase_program_name() -> Option<String> {
pub fn to_string_lossy<S: AsRef<OsStr>>(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);
}

0 comments on commit 762cfe6

Please sign in to comment.