mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-29 06:51:01 +00:00
* 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
1 changed files with 6 additions and 1 deletions
|
@ -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…
Reference in a new issue