mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 12:47:11 -05:00
* add anki_i18n and locale_config crates to launcher * add launcher.ftl * add tr to state * replace most hardcoded strings with translations * add support for `launcher` rustcfg to trim translations * use marker structs to denote type of translations * move underscores into generated code * Update cargo-license, which may fix the license order issue (dae)
52 lines
1.5 KiB
Rust
52 lines
1.5 KiB
Rust
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
mod check;
|
|
mod extract;
|
|
mod gather;
|
|
mod python;
|
|
mod typescript;
|
|
mod write_strings;
|
|
|
|
use std::env;
|
|
use std::path::PathBuf;
|
|
|
|
use anki_io::create_dir_all;
|
|
use anki_io::write_file_if_changed;
|
|
use anyhow::Result;
|
|
use check::check;
|
|
use extract::get_modules;
|
|
use gather::get_ftl_data;
|
|
use write_strings::write_strings;
|
|
|
|
// fixme: check all variables are present in translations as well?
|
|
|
|
fn main() -> Result<()> {
|
|
// generate our own requirements
|
|
let mut map = get_ftl_data();
|
|
check(&map);
|
|
let mut modules = get_modules(&map);
|
|
write_strings(&map, &modules, "strings.rs", "All");
|
|
|
|
typescript::write_ts_interface(&modules)?;
|
|
python::write_py_interface(&modules)?;
|
|
|
|
// write strings.json file to requested path
|
|
println!("cargo:rerun-if-env-changed=STRINGS_JSON");
|
|
if let Ok(path) = env::var("STRINGS_JSON") {
|
|
if !path.is_empty() {
|
|
let path = PathBuf::from(path);
|
|
let meta_json = serde_json::to_string_pretty(&modules).unwrap();
|
|
create_dir_all(path.parent().unwrap())?;
|
|
write_file_if_changed(path, meta_json)?;
|
|
}
|
|
}
|
|
|
|
// generate strings for the launcher
|
|
map.iter_mut()
|
|
.for_each(|(_, modules)| modules.retain(|module, _| module == "launcher"));
|
|
modules.retain(|module| module.name == "launcher");
|
|
write_strings(&map, &modules, "strings_launcher.rs", "Launcher");
|
|
|
|
Ok(())
|
|
}
|