Flatten $translations
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@290 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
81dbdda552
commit
bba76d8df6
26
_compile.php
26
_compile.php
|
@ -4,9 +4,9 @@ function add_apo_slashes($s) {
|
|||
}
|
||||
|
||||
function remove_lang($match) {
|
||||
global $LANG, $translations;
|
||||
global $translations;
|
||||
$idf = strtr($match[2], array("\\'" => "'", "\\\\" => "\\"));
|
||||
$s = ($translations[$LANG][$idf] ? $translations[$LANG][$idf] : $idf);
|
||||
$s = ($translations[$idf] ? $translations[$idf] : $idf);
|
||||
if ($match[3] == ",") {
|
||||
return "$match[1]" . (is_array($s) ? "lang(array('" . implode("', '", array_map('add_apo_slashes', $s)) . "')," : "sprintf('" . add_apo_slashes($s) . "',");
|
||||
}
|
||||
|
@ -15,14 +15,14 @@ function remove_lang($match) {
|
|||
|
||||
function put_file($match) {
|
||||
if ($match[4] == './lang/$LANG.inc.php') {
|
||||
$return = "";
|
||||
if (!$_COOKIE["lang"]) {
|
||||
foreach (glob("./lang/*.inc.php") as $filename) {
|
||||
$match[4] = $filename;
|
||||
$return .= put_file($match);
|
||||
}
|
||||
if ($_COOKIE["lang"]) {
|
||||
return "";
|
||||
}
|
||||
return $return;
|
||||
$return = "switch (\$LANG) {\n";
|
||||
foreach (glob("./lang/*.inc.php") as $filename) {
|
||||
$return .= "case '" . basename($filename, '.inc.php') . "': " . substr(file_get_contents($filename), 6) . "break;\n";
|
||||
}
|
||||
return "$return}\n";
|
||||
}
|
||||
$return = file_get_contents($match[4]);
|
||||
if ($match[4] == "./lang.inc.php" && $_COOKIE["lang"] && (preg_match("~case '$_COOKIE[lang]': (.*) break;~", $return, $match2) || preg_match("~default: (.*)~", $return, $match2))) {
|
||||
|
@ -45,17 +45,15 @@ error_reporting(E_ALL & ~E_NOTICE);
|
|||
if ($_SERVER["argc"] > 1) {
|
||||
$_COOKIE["lang"] = $_SERVER["argv"][1];
|
||||
include "./lang.inc.php";
|
||||
if ($_SERVER["argc"] != 2 || !isset($translations[$_COOKIE["lang"]])) {
|
||||
if ($_SERVER["argc"] != 2 || !isset($langs[$_COOKIE["lang"]])) {
|
||||
echo "Usage: php _compile.php [lang]\nPurpose: Compile phpMinAdmin[-lang].php from index.php.\n";
|
||||
exit(1);
|
||||
}
|
||||
include "./lang/$_COOKIE[lang].inc.php";
|
||||
}
|
||||
$filename = "phpMinAdmin.php";
|
||||
|
||||
$filename = "phpMinAdmin" . ($_COOKIE["lang"] ? "-$_COOKIE[lang]" : "") . ".php";
|
||||
$file = file_get_contents("index.php");
|
||||
if ($_COOKIE["lang"]) {
|
||||
$filename = "phpMinAdmin-$_COOKIE[lang].php";
|
||||
}
|
||||
$file = preg_replace_callback('~(<\\?php)?\\s*(include|require)(_once)? "([^"]*)";(\\s*\\?>)?~', 'put_file', $file);
|
||||
if ($_COOKIE["lang"]) {
|
||||
$file = preg_replace_callback("~(<\\?php\\s*echo )?lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])(;\\s*\\?>)?~s", 'remove_lang', $file);
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
<?php
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
if ($_SERVER["argc"] > 1) {
|
||||
$_COOKIE["lang"] = $_SERVER["argv"][1];
|
||||
include "./lang.inc.php";
|
||||
if ($_SERVER["argc"] != 2 || !isset($translations[$_COOKIE["lang"]])) {
|
||||
if ($_SERVER["argc"] != 2 || !isset($langs[$_COOKIE["lang"]])) {
|
||||
echo "Usage: php _lang.php [lang]\nPurpose: Update lang.inc.php from source code messages.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
@ -19,7 +20,7 @@ foreach (glob("*.php") as $filename) {
|
|||
foreach (($_COOKIE["lang"] ? array("lang/$_COOKIE[lang].inc.php") : glob("lang/*.inc.php")) as $filename) {
|
||||
$messages = $messages_all;
|
||||
preg_match_all("~^(\\s*)(?:// )?(('(?:[^\\\\']+|\\\\.)*') => .*[^,\n]),?~m", file_get_contents($filename), $matches, PREG_SET_ORDER);
|
||||
$s = "<?php\n\$translations['" . basename($filename, ".inc.php") . "'] = array(\n";
|
||||
$s = "<?php\n\$translations = array(\n";
|
||||
foreach ($matches as $match) {
|
||||
if (isset($messages[$match[3]])) {
|
||||
$s .= "$match[1]$match[2],\n";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
$translations['cs'] = array(
|
||||
$translations = array(
|
||||
'Login' => 'Přihlásit se',
|
||||
'phpMinAdmin' => 'phpMinAdmin',
|
||||
'Logout successful.' => 'Odhlášení proběhlo v pořádku.',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
$translations['en'] = array(
|
||||
$translations = array(
|
||||
'Query executed OK, %d row(s) affected.' => array('Query executed OK, %d row affected.', 'Query executed OK, %d rows affected.'),
|
||||
'%d byte(s)' => array('%d byte', '%d bytes'),
|
||||
'Routine has been called, %d row(s) affected.' => array('Routine has been called, %d row affected.', 'Routine has been called, %d rows affected.'),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
$translations['sk'] = array(
|
||||
$translations = array(
|
||||
'Login' => 'Prihlásiť sa',
|
||||
'phpMinAdmin' => 'phpMinAdmin',
|
||||
'Logout successful.' => 'Odhlásenie prebehlo v poriadku',
|
||||
|
|
Loading…
Reference in a new issue