Added default game edition prediction based on system locale

This commit is contained in:
Observer KRypt0n_ 2022-08-06 10:50:31 +02:00
parent cd76c22812
commit bc4a246ce1
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2

View file

@ -22,7 +22,22 @@ pub enum GameEdition {
impl Default for GameEdition { impl Default for GameEdition {
fn default() -> Self { 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
}
} }
} }