1
0
Fork 0
mirror of https://github.com/lise-henry/crowbook synced 2024-05-24 01:46:04 +02:00
crowbook/build.rs

45 lines
1.5 KiB
Rust
Raw Normal View History

2022-01-15 19:21:03 +01:00
use crowbook_intl::{Extractor, Localizer};
2019-02-28 17:33:18 +01:00
2016-10-26 16:11:09 +02:00
use std::env;
2022-01-15 19:21:03 +01:00
use std::path::Path;
2016-10-26 15:35:10 +02:00
2016-10-07 20:47:21 +02:00
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=lang/fr.po");
// Extract and localize src/lib
2016-10-09 02:45:19 +02:00
let mut extractor = Extractor::new();
2022-01-15 19:21:03 +01:00
extractor
.add_messages_from_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/src/lib"))
.unwrap();
// Uncomment to update crowbook.pot
2019-07-18 23:16:55 +02:00
//extractor.write_pot_file(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/lib/crowbook.pot")).unwrap();
2020-01-08 18:37:03 +01:00
2016-10-14 03:48:57 +02:00
let mut localizer = Localizer::new(&extractor);
2022-01-15 19:21:03 +01:00
localizer
.add_lang(
"fr",
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/lib/fr.po")),
)
.unwrap();
let dest_path = Path::new(&env::var("OUT_DIR").unwrap()).join("localize_macros.rs");
2016-11-11 15:31:36 +01:00
localizer.write_macro_file(dest_path).unwrap();
// Extract and localize src/bin
let mut extractor = Extractor::new();
2022-01-15 19:21:03 +01:00
extractor
.add_messages_from_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/src/bin"))
.unwrap();
// Uncomment to update crowbook.pot
2019-07-18 23:16:55 +02:00
//extractor.write_pot_file(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/bin/crowbook.pot")).unwrap();
2020-01-08 18:37:03 +01:00
let mut localizer = Localizer::new(&extractor);
2022-01-15 19:21:03 +01:00
localizer
.add_lang(
"fr",
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/bin/fr.po")),
)
.unwrap();
let dest_path = Path::new(&env::var("OUT_DIR").unwrap()).join("localize_macros_bin.rs");
localizer.write_macro_file(dest_path).unwrap();
2016-10-07 20:47:21 +02:00
}