2007-07-05 10:46:44 +00:00
|
|
|
<?php
|
2007-08-04 19:36:01 +00:00
|
|
|
error_reporting(E_ALL & ~E_NOTICE);
|
2007-07-05 10:46:44 +00:00
|
|
|
if ($_SERVER["argc"] > 1) {
|
2007-07-26 16:47:28 +00:00
|
|
|
$_COOKIE["lang"] = $_SERVER["argv"][1];
|
|
|
|
include "./lang.inc.php";
|
2007-08-04 19:36:01 +00:00
|
|
|
if ($_SERVER["argc"] != 2 || !isset($langs[$_COOKIE["lang"]])) {
|
2007-07-26 16:47:28 +00:00
|
|
|
echo "Usage: php _lang.php [lang]\nPurpose: Update lang.inc.php from source code messages.\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
2007-07-05 10:46:44 +00:00
|
|
|
}
|
|
|
|
|
2007-07-09 06:12:22 +00:00
|
|
|
$messages_all = array();
|
2007-07-05 10:46:44 +00:00
|
|
|
foreach (glob("*.php") as $filename) {
|
|
|
|
$file = file_get_contents($filename);
|
2007-07-10 18:53:35 +00:00
|
|
|
if (preg_match_all("~lang\\(('(?:[^\\\\']+|\\\\.)*')([),])~", $file, $matches)) {
|
2007-07-09 15:28:37 +00:00
|
|
|
$messages_all += array_combine($matches[1], $matches[2]);
|
|
|
|
}
|
2007-07-05 10:46:44 +00:00
|
|
|
}
|
|
|
|
|
2007-07-26 16:47:28 +00:00
|
|
|
foreach (($_COOKIE["lang"] ? array("lang/$_COOKIE[lang].inc.php") : glob("lang/*.inc.php")) as $filename) {
|
2007-07-09 06:12:22 +00:00
|
|
|
$messages = $messages_all;
|
2007-07-26 16:47:28 +00:00
|
|
|
preg_match_all("~^(\\s*)(?:// )?(('(?:[^\\\\']+|\\\\.)*') => .*[^,\n]),?~m", file_get_contents($filename), $matches, PREG_SET_ORDER);
|
2007-08-07 15:27:51 +00:00
|
|
|
$s = "";
|
2007-07-05 10:46:44 +00:00
|
|
|
foreach ($matches as $match) {
|
|
|
|
if (isset($messages[$match[3]])) {
|
|
|
|
$s .= "$match[1]$match[2],\n";
|
|
|
|
unset($messages[$match[3]]);
|
|
|
|
} else {
|
|
|
|
$s .= "$match[1]// $match[2],\n";
|
|
|
|
}
|
|
|
|
}
|
2007-07-09 15:28:37 +00:00
|
|
|
foreach($messages as $idf => $val) {
|
2007-07-10 11:37:21 +00:00
|
|
|
if ($val == "," && strpos($idf, "%d")) {
|
2007-07-26 16:47:28 +00:00
|
|
|
$s .= "\t$idf => array(),\n";
|
|
|
|
} elseif ($filename != "lang/en.inc.php") {
|
2008-10-27 21:14:23 +00:00
|
|
|
$s .= "\t$idf => null,\n";
|
2007-07-09 06:12:22 +00:00
|
|
|
}
|
2007-07-05 10:46:44 +00:00
|
|
|
}
|
2007-08-07 15:27:51 +00:00
|
|
|
fwrite(fopen($filename, "w"), "<?php\n\$translations = array(\n$s);\n");
|
|
|
|
echo "$filename updated.\n";
|
2007-07-05 10:46:44 +00:00
|
|
|
}
|