summaryrefslogtreecommitdiffstats
path: root/enigmail-fixlang.php
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2010-05-31 19:12:20 +0200
committerRemi Collet <fedora@famillecollet.com>2010-05-31 19:12:20 +0200
commit5683cf77402a772e3d7d132fec36e31335f77acf (patch)
treee1ed1a61f5d89453ae4b61084a7b2c403da9846f /enigmail-fixlang.php
import thunderbird-enigmail-1.0.1
Diffstat (limited to 'enigmail-fixlang.php')
-rw-r--r--enigmail-fixlang.php91
1 files changed, 91 insertions, 0 deletions
diff --git a/enigmail-fixlang.php b/enigmail-fixlang.php
new file mode 100644
index 0000000..188b558
--- /dev/null
+++ b/enigmail-fixlang.php
@@ -0,0 +1,91 @@
+#!/usr/bin/php
+<?php
+function loaddtd ($file, &$tab) {
+
+ echo "+ Loading $file\n";
+ $tab=array();
+
+ $fic=fopen($file, "r");
+ $prev=false;
+ if ($fic) while ($buf=fgets($fic)) {
+ if (empty($buf) || $buf=="\n") {
+ //echo "+ empty\n";
+ } else if (preg_match('/^<!ENTITY (.*)"(.*)">$/', $buf, $res)) {
+ //echo "+ Line '".$res[1]."'\n";
+ $ind=trim($res[1]);
+ $tab[$ind] = $res[1].'"'.$res[2].'">';
+ $prev=false;
+ } else if (preg_match('/^<!ENTITY (.*)"(.*)$/', $buf, $res)) {
+ //echo "+ Start '".$res[1]."'\n";
+ $ind=trim($res[1]);
+ $tab[$ind] = $res[1].'"'.$res[2];
+ $prev=$ind;
+ } else if ($prev && preg_match('/^(.*)">$/', $buf, $res)) {
+ //echo "+ End '".$prev."'\n";
+ $tab[$prev] .= "\n".$res[1].'">';
+ $prev=false;
+ } else if ($prev && preg_match('/^(.*)$/', $buf, $res)) {
+ //echo "+ Cont. '".$prev."'\n";
+ $tab[$prev] .= "\n".$res[1];
+ } else {
+ die("- unkonwn ($buf) !\n");
+ }
+ }
+}
+function loadprop ($file, &$tab) {
+
+ echo "+ Loading $file\n";
+ $tab=array();
+
+ $fic=fopen($file, "r");
+ if ($fic) while ($buf=fgets($fic)) {
+ if (empty($buf) || $buf=="\n") {
+ //echo "+ empty\n";
+ } else if (preg_match('/^#/', $buf, $res)) {
+ //echo "+ comments\n";
+ } else if (preg_match('/^([A-Za-z0-9._]*)[[:space:]]*=[[:space:]]*(.*)/', $buf, $res)) {
+ //echo "+ Value '".$res[1]."'\n";
+ $ind=trim($res[1]);
+ $tab[$ind] = $res[1].'='.$res[2];
+ } else {
+ echo("\tIgnored ($buf) !\n");
+ }
+ }
+}
+if ($_SERVER["argc"]<3) die ("usage enigmail-fixlang.php fromdir destdir\n");
+$from=$_SERVER["argv"][1];
+$dest=$_SERVER["argv"][2];
+if (!is_file("$from/enigmail.dtd")) die ("$from/enigmail.dtd not found\n");
+if (!is_file("$from/enigmail.properties")) die ("$from/enigmail.properties not found\n");
+if (!is_file("$dest/enigmail.dtd")) die ("$dest/enigmail.dtd not found\n");
+if (!is_file("$dest/enigmail.properties")) die ("$dest/enigmail.properties not found\n");
+
+loaddtd("$from/enigmail.dtd", $endtd);
+loaddtd("$dest/enigmail.dtd", $frdtd);
+
+echo "+ Writing $dest/enigmail.dtd\n";
+$fic=fopen("$dest/enigmail.dtd", "w");
+foreach($endtd as $ind => $line)
+ if (isset($frdtd[$ind])) {
+ fputs($fic, "<!ENTITY ".$frdtd[$ind]."\n");
+ } else {
+ echo "\tAdding missing $ind\n";
+ fputs($fic, "<!ENTITY ".$endtd[$ind]."\n");
+ }
+fclose($fic);
+
+loadprop("$from/enigmail.properties", $enprop);
+loadprop("$dest/enigmail.properties", $frprop);
+
+echo "+ Writing $dest/enigmail.properties\n";
+$fic=fopen("$dest/enigmail.properties", "w");
+foreach($enprop as $ind => $line)
+ if (isset($frprop[$ind])) {
+ fputs($fic, $frprop[$ind]."\n");
+ } else {
+ echo "\tAdding missing $ind\n";
+ fputs($fic, $enprop[$ind]."\n");
+ }
+fclose($fic);
+?>
+