Fixed translate crashing on unknown language code, added Ewe

This commit is contained in:
Kirottu
2023-05-01 22:40:19 +03:00
parent 681032e0f2
commit 0e5fd5d1bf

View File

@@ -56,6 +56,7 @@ fn init(config_dir: RString) -> State {
("nl", "Dutch"),
("en", "English"),
("eo", "Esperanto"),
("ee", "Ewe"),
("et", "Estonian"),
("tl", "Filipino"),
("fi", "Finnish"),
@@ -216,10 +217,10 @@ fn get_matches(input: RString, data: &State) -> RVec<Match> {
"{} -> {}",
data.langs.iter()
.find_map(|(code, name)| if *code == json[2].as_str().expect("Malformed JSON!") {
Some(name)
Some(*name)
} else {
None
}).expect("Google API returned unknown language code!"),
}).unwrap_or_else(|| json[2].as_str().expect("Malformed JSON!")),
name)
.into()),
use_pango: false,