fix(i18n): forced format_lang to return regions for language codes

Standard German language code is `de` but game API requires it to be `de-de`.
With this change formatted locales always will have
region so always will fit game requirements
This commit is contained in:
Observer KRypt0n_ 2023-03-04 23:24:37 +02:00
parent da7540ba4b
commit f109454cb7

View file

@ -54,14 +54,10 @@ pub fn get_default_lang() -> LanguageIdentifier {
}
pub fn format_lang(lang: &LanguageIdentifier) -> String {
let mut formatted = lang.language.to_string();
if let Some(region) = lang.region {
formatted += "-";
formatted += &region.to_string().to_ascii_lowercase();
}
formatted
format!("{}-{}", lang.language, match lang.region {
Some(region) => region.to_string().to_ascii_lowercase(),
None => lang.language.to_string()
})
}
/// Get translated message by key