Skip to content

Commit

Permalink
Merge pull request #528 from anstadnik/english
Browse files Browse the repository at this point in the history
Download multiple languages
  • Loading branch information
anstadnik authored May 24, 2024
2 parents 3b444c7 + 35adfc7 commit 18fb0e8
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions core/src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,16 @@ pub fn get_data_from_file(filename: &str) -> anyhow::Result<MultilangFs> {

pub async fn get_data_from_web() -> anyhow::Result<MultilangFs> {
let sheet_id = env!("SHEET_ID");
assert!(Lang::iter().count() == 1, "Only one language is supported");
let lang = Lang::iter().next().unwrap();
let sheet_name = lang.name();
let url = format!(
"https://docs.google.com/spreadsheets/d/{}/gviz/tq?tqx=out:csv&sheet={}",
sheet_id, sheet_name
);
let rdr = Reader::from_reader(reqwest::get(url).await?.bytes().await?.reader());
Ok([(lang, get_finite_state(rdr, lang)?)].into())
// assert!(Lang::iter().count() == 1, "Only one language is supported");
let mut ret = MultilangFs::default();
for lang in Lang::iter() {
let url = format!(
"https://docs.google.com/spreadsheets/d/{}/gviz/tq?tqx=out:csv&sheet={}",
sheet_id,
lang.name()
);
let rdr = Reader::from_reader(reqwest::get(url).await?.bytes().await?.reader());
ret.insert(lang, get_finite_state(rdr, lang)?);
}
Ok(ret)
}

0 comments on commit 18fb0e8

Please sign in to comment.