* syntax and names * Solve the issue #642, by searching index of english language code in catalog.
This commit is contained in:
parent
28fb50438e
commit
935d331e97
|
@ -46,10 +46,15 @@ lazy_static! {
|
||||||
let catalogs = include_i18n!();
|
let catalogs = include_i18n!();
|
||||||
let lang = js! { return navigator.language }.into_string().unwrap();
|
let lang = js! { return navigator.language }.into_string().unwrap();
|
||||||
let lang = lang.splitn(2, '-').next().unwrap_or("en");
|
let lang = lang.splitn(2, '-').next().unwrap_or("en");
|
||||||
|
|
||||||
|
let english_position = catalogs
|
||||||
|
.iter()
|
||||||
|
.position(|(language_code, _)| *language_code == "en")
|
||||||
|
.unwrap();
|
||||||
catalogs
|
catalogs
|
||||||
.iter()
|
.iter()
|
||||||
.find(|(l, _)| l == &lang)
|
.find(|(l, _)| l == &lang)
|
||||||
.unwrap_or(&catalogs[0])
|
.unwrap_or(&catalogs[english_position])
|
||||||
.clone()
|
.clone()
|
||||||
.1
|
.1
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue