From bc4a246ce1b5cfe5878344c85cc0c2698d180eae Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sat, 6 Aug 2022 10:50:31 +0200 Subject: [PATCH] Added default game edition prediction based on system locale --- src/lib/config/launcher/mod.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/lib/config/launcher/mod.rs b/src/lib/config/launcher/mod.rs index 51cea24..ea2dfc0 100644 --- a/src/lib/config/launcher/mod.rs +++ b/src/lib/config/launcher/mod.rs @@ -22,7 +22,22 @@ pub enum GameEdition { impl Default for GameEdition { fn default() -> Self { - Self::Global + let locale = match std::env::var("LC_ALL") { + Ok(locale) => locale, + Err(_) => match std::env::var("LC_MESSAGES") { + Ok(locale) => locale, + Err(_) => match std::env::var("LANG") { + Ok(locale) => locale, + Err(_) => return Self::Global + } + } + }; + + if locale.len() > 4 && &locale[..5].to_lowercase() == "zh_cn" { + Self::China + } else { + Self::Global + } } }