Translation system: fixes and updates

Add script (compare_pot) for comparing templates module comments,
   and sending reminder emails if they differ.
Add script (buid_pos) for generating all templates and comparing
   them with current versions.
This commit is contained in:
David Anderson 2013-10-15 11:19:59 -07:00
parent 52152a5a4c
commit c6346bef5f
4 changed files with 70 additions and 5 deletions

30
build_pos Executable file
View File

@ -0,0 +1,30 @@
#! /usr/bin/env php
<?php
// Generate translation templates from source code.
// Compare them with the current versions in trunk;
// if they differ, send email telling us to validate and commit
// the new versions.
$emails = "davea@ssl.berkeley.edu";
$tdir = "locale/templates";
system("cd doc; build_po.php");
system("tools/compare_pot doc/BOINC-Web.pot $tdir/BOINC-Web.pot $emails");
system("cd html/user; build_po_boinc.php");
system("tools/compare_pot html/ops/BOINC-Project-Generic.pot $tdir/BOINC-Project-Generic.pot $emails");
system("cd client; build_po");
system("tools/compare_pot client/BOINC-Client.pot $tdir/BOINC-Client.pot $emails");
system("cd clientgui; build_po");
system("tools/compare_pot clientgui/BOINC-Manager.pot $tdir/BOINC-Manager.pot $emails");
system("cd mac_installer; build_po");
system("tools/compare_pot mac_installer/BOINC-Setup.pot $tdir/BOINC-Setup.pot $emails");
system("cd android; a2po export -v");
system("tools/compare_pot android/BOINC-Android.pot $tdir/BOINC-Android.pot $emails");
?>

View File

@ -1,4 +1,5 @@
#! /bin/sh
xgettext --keyword=_ -C -o ../locale/templates/BOINC-Manager.pot *.cpp msw/*.cpp mac/*.cpp gtk/*.cpp
xgettext --from-code=UTF-8 --keyword=_ -C -o BOINC-Manager.pot *.cpp msw/*.cpp mac/*.cpp gtk/*.cpp
../tools/compare_pot BOINC-Manager.pot ../locale/templates/BOINC-Manager.pot davea@ssl.berkeley.edu

View File

@ -38,7 +38,7 @@ msgstr ""
HDR;
$out = fopen("en.po", "w");
$out = fopen("BOINC-Project-Generic.pot", "w");
fwrite($out, $header);
@ -51,8 +51,6 @@ stream_copy_to_stream($pipe, $out);
fclose($pipe);
fclose($out);
system("mv en.po ../../locale/templates/BOINC-Project-Generic.pot\n");
echo "Done\n";
?>

36
tools/compare_pot Executable file
View File

@ -0,0 +1,36 @@
#! /usr/bin/env php
<?php
// compare_pot file1 file2 [--email email_addr ...]
//
// compare two .pot files, ignoring comments.
// If they differ, send email to the given addresses
function strip_comments($x) {
$y = "";
foreach ($x as $l) {
if (substr($l, 0, 1) != '#') $y .= $l;
}
return $y;
}
function pot_same($f1, $f2) {
$c1 = strip_comments(file($f1));
$c2 = strip_comments(file($f2));
return ($c1 == $c2);
}
if ($argc < 3) die("Usage\n");
if (pot_same($argv[1], $argv[2])) {
echo "files match\n";
} else {
echo "files don't match\n";
for ($i=3; $i<$argc; $i++) {
mail($argv[$i],
$argv[1]." updated",
$argv[1]." was updated. Please review, copy to boinc/locale/templates, and commit"
);
}
}
?>