mirror of
https://github.com/vrana/adminer.git
synced 2025-08-11 09:04:02 +02:00
Comments
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@729 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
11
lang.php
11
lang.php
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
if ($_SERVER["argc"] > 1) {
|
||||
$_COOKIE["lang"] = $_SERVER["argv"][1];
|
||||
$_COOKIE["lang"] = $_SERVER["argv"][1]; // Adminer functions read language from cookie
|
||||
include dirname(__FILE__) . "/adminer/include/lang.inc.php";
|
||||
if ($_SERVER["argc"] != 2 || !isset($langs[$_COOKIE["lang"]])) {
|
||||
echo "Usage: php lang.php [lang]\nPurpose: Update lang/*.inc.php from source code messages.\n";
|
||||
echo "Usage: php lang.php [lang]\nPurpose: Update adminer/lang/*.inc.php from source code messages.\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ if ($_SERVER["argc"] > 1) {
|
||||
$messages_all = array();
|
||||
foreach (array_merge(glob(dirname(__FILE__) . "/adminer/*.php"), glob(dirname(__FILE__) . "/adminer/include/*.php")) as $filename) {
|
||||
$file = file_get_contents($filename);
|
||||
if (preg_match_all("~lang\\(('(?:[^\\\\']+|\\\\.)*')([),])~", $file, $matches)) {
|
||||
if (preg_match_all("~lang\\(('(?:[^\\\\']+|\\\\.)*')([),])~", $file, $matches)) { // lang() always uses apostrophes
|
||||
$messages_all += array_combine($matches[1], $matches[2]);
|
||||
}
|
||||
}
|
||||
@@ -23,19 +23,22 @@ foreach (glob(dirname(__FILE__) . "/adminer/lang/" . ($_COOKIE["lang"] ? $_COOKI
|
||||
$s = "";
|
||||
foreach ($matches as $match) {
|
||||
if (isset($messages[$match[3]])) {
|
||||
// keep current messages
|
||||
$s .= "$match[1]$match[2],\n";
|
||||
unset($messages[$match[3]]);
|
||||
} else {
|
||||
// comment deprecated messages
|
||||
$s .= "$match[1]// $match[2],\n";
|
||||
}
|
||||
}
|
||||
foreach($messages as $idf => $val) {
|
||||
// add new messages
|
||||
if ($val == "," && strpos($idf, "%d")) {
|
||||
$s .= "\t$idf => array(),\n";
|
||||
} elseif (basename($filename) != "en.inc.php") {
|
||||
$s .= "\t$idf => null,\n";
|
||||
}
|
||||
}
|
||||
fwrite(fopen($filename, "w"), "<?php\n\$translations = array(\n$s);\n");
|
||||
fwrite(fopen($filename, "w"), "<?php\n\$translations = array(\n$s);\n"); // file_put_contents() since PHP 5
|
||||
echo "$filename updated.\n";
|
||||
}
|
||||
|
Reference in New Issue
Block a user