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) {
|
2009-06-21 23:31:12 +00:00
|
|
|
$_COOKIE["adminer_lang"] = $_SERVER["argv"][1]; // Adminer functions read language from cookie
|
2009-06-13 20:55:19 +00:00
|
|
|
include dirname(__FILE__) . "/adminer/include/lang.inc.php";
|
2009-06-21 23:31:12 +00:00
|
|
|
if ($_SERVER["argc"] != 2 || !isset($langs[$_COOKIE["adminer_lang"]])) {
|
2009-06-21 23:20:32 +00:00
|
|
|
echo "Usage: php lang.php [lang]\nPurpose: Update adminer/lang/*.inc.php from source code messages.\n";
|
2007-07-26 16:47:28 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2007-07-05 10:46:44 +00:00
|
|
|
}
|
|
|
|
|
2007-07-09 06:12:22 +00:00
|
|
|
$messages_all = array();
|
2009-06-13 20:55:19 +00:00
|
|
|
foreach (array_merge(glob(dirname(__FILE__) . "/adminer/*.php"), glob(dirname(__FILE__) . "/adminer/include/*.php")) as $filename) {
|
2007-07-05 10:46:44 +00:00
|
|
|
$file = file_get_contents($filename);
|
2009-06-21 23:20:32 +00:00
|
|
|
if (preg_match_all("~lang\\(('(?:[^\\\\']+|\\\\.)*')([),])~", $file, $matches)) { // lang() always uses apostrophes
|
2007-07-09 15:28:37 +00:00
|
|
|
$messages_all += array_combine($matches[1], $matches[2]);
|
|
|
|
}
|
2007-07-05 10:46:44 +00:00
|
|
|
}
|
|
|
|
|
2009-06-21 23:31:12 +00:00
|
|
|
foreach (glob(dirname(__FILE__) . "/adminer/lang/" . ($_COOKIE["adminer_lang"] ? $_COOKIE["adminer_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]])) {
|
2009-06-21 23:20:32 +00:00
|
|
|
// keep current messages
|
2007-07-05 10:46:44 +00:00
|
|
|
$s .= "$match[1]$match[2],\n";
|
|
|
|
unset($messages[$match[3]]);
|
|
|
|
} else {
|
2009-06-21 23:20:32 +00:00
|
|
|
// comment deprecated messages
|
2007-07-05 10:46:44 +00:00
|
|
|
$s .= "$match[1]// $match[2],\n";
|
|
|
|
}
|
|
|
|
}
|
2007-07-09 15:28:37 +00:00
|
|
|
foreach($messages as $idf => $val) {
|
2009-06-21 23:20:32 +00:00
|
|
|
// add new messages
|
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";
|
2009-06-01 21:29:18 +00:00
|
|
|
} elseif (basename($filename) != "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
|
|
|
}
|
2009-06-21 23:20:32 +00:00
|
|
|
fwrite(fopen($filename, "w"), "<?php\n\$translations = array(\n$s);\n"); // file_put_contents() since PHP 5
|
2007-08-07 15:27:51 +00:00
|
|
|
echo "$filename updated.\n";
|
2007-07-05 10:46:44 +00:00
|
|
|
}
|