Fix issue #642, frontend not in english if the user language does not exist (#648)

* syntax and names

* Solve the issue #642, by searching index of english language code in catalog.
pull/656/head
Requiem 5 years ago committed by Ana Gelez
parent 28fb50438e
commit 935d331e97

@ -46,10 +46,15 @@ lazy_static! {
let catalogs = include_i18n!();
let lang = js! { return navigator.language }.into_string().unwrap();
let lang = lang.splitn(2, '-').next().unwrap_or("en");
let english_position = catalogs
.iter()
.position(|(language_code, _)| *language_code == "en")
.unwrap();
catalogs
.iter()
.find(|(l, _)| l == &lang)
.unwrap_or(&catalogs[0])
.unwrap_or(&catalogs[english_position])
.clone()
.1
};

Loading…
Cancel
Save