mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-12-22 18:16:30 +00:00
Add a build script to update/create translation files
This commit is contained in:
parent
327768d3fe
commit
978104b518
5 changed files with 95 additions and 0 deletions
45
build.rs
Normal file
45
build.rs
Normal file
|
@ -0,0 +1,45 @@
|
|||
use std::fs::File;
|
||||
use std::io::{BufReader, prelude::*};
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
update_po();
|
||||
compile_po();
|
||||
install_po();
|
||||
}
|
||||
|
||||
fn update_po() {
|
||||
let pot_path = Path::new("po").join("plume.pot");
|
||||
|
||||
let linguas_file = File::open(Path::new("po").join("LINGUAS")).expect("Couldn't find po/LINGUAS file");
|
||||
let linguas = BufReader::new(&linguas_file);
|
||||
for lang in linguas.lines() {
|
||||
let lang = lang.unwrap();
|
||||
let po_path = Path::new("po").join(format!("{}.po", lang.clone()));
|
||||
if po_path.exists() && po_path.is_file() {
|
||||
println!("Updating {}", lang.clone());
|
||||
// Update it
|
||||
Command::new("msgmerge")
|
||||
.arg(po_path.to_str().unwrap())
|
||||
.arg(pot_path.to_str().unwrap())
|
||||
.spawn()
|
||||
.expect("Couldn't update PO file");
|
||||
} else {
|
||||
println!("Creating {}", lang.clone());
|
||||
// Create it from the template
|
||||
Command::new("msginit")
|
||||
.arg(format!("--input={}", pot_path.to_str().unwrap()))
|
||||
.arg(format!("--output-file={}", po_path.to_str().unwrap()))
|
||||
.arg("-l")
|
||||
.arg(lang)
|
||||
.arg("--no-translator")
|
||||
.spawn()
|
||||
.expect("Couldn't init PO file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn compile_po() {}
|
||||
|
||||
fn install_po() {}
|
2
po/LINGUAS
Normal file
2
po/LINGUAS
Normal file
|
@ -0,0 +1,2 @@
|
|||
en
|
||||
fr
|
16
po/en.po
Normal file
16
po/en.po
Normal file
|
@ -0,0 +1,16 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: plume\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-06-15 16:33-0700\n"
|
||||
"PO-Revision-Date: 2018-06-15 16:35+0100\n"
|
||||
"Last-Translator: baptiste <baptiste@gelez.xyz>\n"
|
||||
"Language-Team: English\n"
|
||||
"Language: en_US\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
msgid "Welcome on %s"
|
||||
msgstr "Welcome on %s"
|
16
po/fr.po
Normal file
16
po/fr.po
Normal file
|
@ -0,0 +1,16 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: plume\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-06-15 16:33-0700\n"
|
||||
"PO-Revision-Date: 2018-06-15 16:33-0700\n"
|
||||
"Last-Translator: Automatically generated\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
msgid "Welcome on %s"
|
||||
msgstr ""
|
16
po/plume.pot
Normal file
16
po/plume.pot
Normal file
|
@ -0,0 +1,16 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: plume\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-06-15 16:33-0700\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
||||
|
||||
msgid "Welcome on %s"
|
||||
msgstr ""
|
Loading…
Reference in a new issue