mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 12:47:11 -05:00
codegen i18n ts for launcher
This commit is contained in:
parent
3b3dce1105
commit
8c6607ff2a
4 changed files with 7 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
[env]
|
[env]
|
||||||
STRINGS_PY = { value = "out/pylib/anki/_fluent.py", relative = true }
|
STRINGS_PY = { value = "out/pylib/anki/_fluent.py", relative = true }
|
||||||
STRINGS_TS = { value = "out/ts/lib/generated/ftl.ts", relative = true }
|
STRINGS_TS = { value = "out/ts/lib/generated/ftl.ts", relative = true }
|
||||||
|
STRINGS_LAUNCHER_TS = { value = "out/ts/lib/generated/ftl-launcher.ts", relative = true }
|
||||||
DESCRIPTORS_BIN = { value = "out/rslib/proto/descriptors.bin", relative = true }
|
DESCRIPTORS_BIN = { value = "out/rslib/proto/descriptors.bin", relative = true }
|
||||||
# build script will append .exe if necessary
|
# build script will append .exe if necessary
|
||||||
PROTOC = { value = "out/extracted/protoc/bin/protoc", relative = true }
|
PROTOC = { value = "out/extracted/protoc/bin/protoc", relative = true }
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ fn prepare_translations(build: &mut Build) -> Result<()> {
|
||||||
outputs: &[
|
outputs: &[
|
||||||
RustOutput::Data("py", "pylib/anki/_fluent.py"),
|
RustOutput::Data("py", "pylib/anki/_fluent.py"),
|
||||||
RustOutput::Data("ts", "ts/lib/generated/ftl.ts"),
|
RustOutput::Data("ts", "ts/lib/generated/ftl.ts"),
|
||||||
|
RustOutput::Data("launcher_ts", "ts/lib/generated/ftl_launcher.ts"),
|
||||||
],
|
],
|
||||||
target: None,
|
target: None,
|
||||||
extra_args: "-p anki_i18n",
|
extra_args: "-p anki_i18n",
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ fn main() -> Result<()> {
|
||||||
let mut modules = get_modules(&map);
|
let mut modules = get_modules(&map);
|
||||||
write_strings(&map, &modules, "strings.rs", "All");
|
write_strings(&map, &modules, "strings.rs", "All");
|
||||||
|
|
||||||
typescript::write_ts_interface(&modules)?;
|
typescript::write_ts_interface(&modules, "STRINGS_TS")?;
|
||||||
python::write_py_interface(&modules)?;
|
python::write_py_interface(&modules)?;
|
||||||
|
|
||||||
// write strings.json file to requested path
|
// write strings.json file to requested path
|
||||||
|
|
@ -48,5 +48,7 @@ fn main() -> Result<()> {
|
||||||
modules.retain(|module| module.name == "launcher");
|
modules.retain(|module| module.name == "launcher");
|
||||||
write_strings(&map, &modules, "strings_launcher.rs", "Launcher");
|
write_strings(&map, &modules, "strings_launcher.rs", "Launcher");
|
||||||
|
|
||||||
|
typescript::write_ts_interface(&modules, "STRINGS_LAUNCHER_TS")?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,14 @@ use crate::extract::Module;
|
||||||
use crate::extract::Variable;
|
use crate::extract::Variable;
|
||||||
use crate::extract::VariableKind;
|
use crate::extract::VariableKind;
|
||||||
|
|
||||||
pub fn write_ts_interface(modules: &[Module]) -> Result<()> {
|
pub fn write_ts_interface(modules: &[Module], path_key: &str) -> Result<()> {
|
||||||
let mut ts_out = header();
|
let mut ts_out = header();
|
||||||
write_imports(&mut ts_out);
|
write_imports(&mut ts_out);
|
||||||
|
|
||||||
render_module_map(modules, &mut ts_out);
|
render_module_map(modules, &mut ts_out);
|
||||||
render_methods(modules, &mut ts_out);
|
render_methods(modules, &mut ts_out);
|
||||||
|
|
||||||
if let Ok(path) = env::var("STRINGS_TS") {
|
if let Ok(path) = env::var(path_key) {
|
||||||
let path = PathBuf::from(path);
|
let path = PathBuf::from(path);
|
||||||
create_dir_all(path.parent().unwrap())?;
|
create_dir_all(path.parent().unwrap())?;
|
||||||
write_file_if_changed(path, ts_out)?;
|
write_file_if_changed(path, ts_out)?;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue