-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
42 lines (35 loc) · 1.04 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use std::{
env,
error::Error,
fs::{create_dir_all, read_dir},
path::Path,
process::Command,
};
fn main() -> Result<(), Box<dyn Error>> {
if env::var("GEN_GETTEXT").is_err() {
return Ok(());
}
create_dir_all(concat!(env!("CARGO_MANIFEST_DIR"), "/mo/"))?;
let po_dir = concat!(env!("CARGO_MANIFEST_DIR"), "/po/");
for i in read_dir(po_dir)?.flatten() {
let p = i.path();
let filename_without_exit = p
.with_extension("")
.file_name()
.map(|x| x.to_string_lossy().to_string())
.unwrap();
if p.extension().is_some_and(|x| x == "po") {
let mo_dir = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("mo")
.join(&filename_without_exit)
.join("LC_MESSAGES");
create_dir_all(&mo_dir)?;
Command::new("msgfmt")
.arg(p)
.arg("-o")
.arg(mo_dir.join("deb-installer.mo"))
.output()?;
}
}
Ok(())
}