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