Эх сурвалжийг харах

fix(i18n): check LANG env var for locale (macOS compat)

On macOS, sys-locale reads system preferences (not the LANG env
var), so LANG=ru_RU.UTF-8 had no effect.  Now we check std::env::var
for LANG first and pass it explicitly to set_locale, falling back
to set_locale(None) (auto-detect via sys-locale) when unset.
Alexander Korolev 4 сар өмнө
parent
commit
53edb54fe8
2 өөрчлөгдсөн 5 нэмэгдсэн , 3 устгасан
  1. 1 1
      README.md
  2. 4 2
      src/main.rs

+ 1 - 1
README.md

@@ -233,7 +233,7 @@ The launcher sets these automatically. Recipe `[env]` overrides any.
 Messages are localized. Auto-detects system locale.
 
 ```bash
-# Override locale
+# Override locale (works on both macOS and Linux)
 LANG=ru_RU.UTF-8 sm121-launcher serve --recipe deepseek-v4-flash
 ```
 

+ 4 - 2
src/main.rs

@@ -57,8 +57,10 @@ fn resolve_config_path(cli_config: &str) -> std::path::PathBuf {
 
 #[tokio::main]
 async fn main() -> Result<()> {
-    // Auto-detect system locale for translations
-    let _ = fluent_i18n::set_locale(None);
+    // Locale: check LANG env var first (works on macOS where sys-locale
+    // reads system prefs instead of the env), fall back to auto-detect.
+    let locale = std::env::var("LANG").ok();
+    let _ = fluent_i18n::set_locale(locale.as_deref());
     tracing_subscriber::fmt::init();
     let cli = Cli::parse();