Forráskód Böngészése

fix(i18n): normalize LANG from 'ru_RU.UTF-8' to 'ru-RU' for unic-langid

The LANG env var format (ru_RU.UTF-8) uses underscores and a .UTF-8
suffix, but unic-langid expects hyphen-separated language-region codes
(e.g. ru-RU).  The parser silently fails, causing fallback to English.
Now strips the .charset suffix and replaces underscores with hyphens.

Verified working:
  LANG=ru_RU.UTF-8  → ✅ Автоподбор кластера: 2nodes-dac (2 узла)
  LANG=en_US.UTF-8  → ✅ Auto-selected cluster: 2nodes-dac (2 nodes)
Alexander Korolev 4 hónapja
szülő
commit
15b97e42fd
2 módosított fájl, 6 hozzáadás és 4 törlés
  1. 1 1
      README.md
  2. 5 3
      src/main.rs

+ 1 - 1
README.md

@@ -234,7 +234,7 @@ Messages are localized. Auto-detects system locale.
 
 ```bash
 # Override locale (works on both macOS and Linux)
-LANG=ru_RU.UTF-8 sm121-launcher serve --recipe deepseek-v4-flash
+LANG=ru_RU.UTF-8 RUST_LOG=info sm121-launcher serve --recipe deepseek-v4-flash
 ```
 
 Available: English (fallback), Russian, Spanish, Italian, French, German.

+ 5 - 3
src/main.rs

@@ -57,9 +57,11 @@ fn resolve_config_path(cli_config: &str) -> std::path::PathBuf {
 
 #[tokio::main]
 async fn main() -> Result<()> {
-    // 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();
+    // Locale: check LANG env var first (macOS sys-locale ignores it).
+    // Normalize "ru_RU.UTF-8" → "ru-RU" for unic-langid.
+    let locale = std::env::var("LANG").ok().map(|l| {
+        l.split('.').next().unwrap_or(&l).replace('_', "-")
+    });
     let _ = fluent_i18n::set_locale(locale.as_deref());
     tracing_subscriber::fmt::init();
     let cli = Cli::parse();