2019-02-28 17:33:18 +01:00
|
|
|
|
2016-10-27 00:50:06 +02:00
|
|
|
use crowbook_intl::{Localizer, Extractor};
|
2016-10-07 20:47:21 +02:00
|
|
|
|
2016-10-26 15:35:10 +02:00
|
|
|
use std::path::Path;
|
2016-10-26 16:11:09 +02:00
|
|
|
use std::env;
|
|
|
|
|
2016-10-26 15:35:10 +02:00
|
|
|
|
2016-10-07 20:47:21 +02:00
|
|
|
fn main() {
|
2016-10-26 16:11:09 +02:00
|
|
|
// println!("cargo:rerun-if-changed=build.rs");
|
2016-12-23 13:35:29 +01:00
|
|
|
// 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();
|
2016-12-23 13:35:29 +01:00
|
|
|
extractor.add_messages_from_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/src/lib")).unwrap();
|
2017-10-10 00:53:44 +02:00
|
|
|
// Uncomment to update crowbook.pot
|
|
|
|
// extractor.write_pot_file(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/lib/crowbook.pot")).unwrap();
|
2016-10-14 03:48:57 +02:00
|
|
|
|
|
|
|
let mut localizer = Localizer::new(&extractor);
|
2016-12-25 20:44:17 +01:00
|
|
|
localizer.add_lang("fr", include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/lib/fr.po"))).unwrap();
|
2016-11-11 15:31:36 +01:00
|
|
|
let dest_path = Path::new(&env::var("OUT_DIR").unwrap())
|
|
|
|
.join("localize_macros.rs");
|
|
|
|
localizer.write_macro_file(dest_path).unwrap();
|
2016-12-23 13:35:29 +01:00
|
|
|
|
|
|
|
// Extract and localize src/bin
|
|
|
|
let mut extractor = Extractor::new();
|
|
|
|
extractor.add_messages_from_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/src/bin")).unwrap();
|
2017-10-10 00:53:44 +02:00
|
|
|
// Uncomment to update crowbook.pot
|
2017-10-10 01:14:36 +02:00
|
|
|
// extractor.write_pot_file(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/bin/crowbook.pot")).unwrap();
|
2016-12-23 13:35:29 +01:00
|
|
|
|
|
|
|
let mut localizer = Localizer::new(&extractor);
|
|
|
|
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
|
|
|
}
|