diff --git a/_compile.php b/_compile.php index ecfae3dd..844d58a2 100644 --- a/_compile.php +++ b/_compile.php @@ -1,7 +1,7 @@ "'", "\\\\" => "\\"))); + $s = lang(strtr($match[2], array("\\'" => "'", "\\\\" => "\\"))); + return ($match[1] && $match[3] ? $s : "$match[1]'" . addcslashes($s, "\\'") . "'$match[3]"); } function put_file($match) { @@ -18,16 +18,25 @@ function put_file($match) { } error_reporting(E_ALL & ~E_NOTICE); +if ($_SERVER["argc"] > 1) { + include "./lang.inc.php"; + if ($_SERVER["argc"] != 2 || !in_array($_SERVER["argv"][1], lang())) { + echo lang('Usage: php _compile.php [lang]') . "\n" . lang('Purpose: Compile phpMinAdmin[-lang].php from index.php.') . "\n"; + exit(1); + } + $_SESSION["lang"] = $_SERVER["argv"][1]; +} +$filename = "phpMinAdmin.php"; $file = file_get_contents("index.php"); -$LANG = (strlen($_SERVER["argv"][1]) == 2 ? $_SERVER["argv"][1] : ""); -if ($LANG) { +if ($_SESSION["lang"]) { + $filename = "phpMinAdmin-$_SESSION[lang].php"; $file = str_replace("include \"./lang.inc.php\";\n", "", $file); } $file = preg_replace_callback('~(<\\?php\\s*)?(include|require)(_once)? "([^"]*)";(\\s*\\?>)?~', 'put_file', $file); -if ($LANG) { - include "./lang.inc.php"; - preg_replace_callback("~(<\\?php\\s*echo )?lang\\('((?:[^\\\\']*|\\\\.)+)'\\)(;\\s*\\?>)?~s", 'remove_lang', $file); +if ($_SESSION["lang"]) { + $file = preg_replace_callback("~(<\\?php\\s*echo )?lang\\('((?:[^\\\\']*|\\\\.)+)'\\)(;\\s*\\?>)?~s", 'remove_lang', $file); + $file = str_replace("\n", "", $file); } //! remove spaces and comments -file_put_contents("phpMinAdmin" . ($LANG ? "-$LANG" : "") . ".php", $file); -echo "phpMinAdmin.php created.\n"; +file_put_contents($filename, $file); +echo "$filename created.\n"; diff --git a/_lang.php b/_lang.php new file mode 100644 index 00000000..e0a717d3 --- /dev/null +++ b/_lang.php @@ -0,0 +1,32 @@ + 1) { + echo "Usage: php _lang.php\nPurpose: Update lang.inc.php from source code messages.\n"; + exit(1); +} + +$messages = array(); +foreach (glob("*.php") as $filename) { + $file = file_get_contents($filename); + preg_match_all("~lang\\(('(?:[^\\\\']*|\\\\.)+')\\)~s", $file, $matches); + $messages += array_flip($matches[1]); +} + +$file = file_get_contents("lang.inc.php"); +preg_match_all("~\n\t\t'.*' => array\\(\n(.*\n)\t\t\\)~sU", $file, $translations, PREG_OFFSET_CAPTURE); +foreach ($translations[1] as $translation) { + preg_match_all("~^(\\s*(?:// )?)(('(?:[^\\\\']*|\\\\.)+') => .*[^,\n]),?~m", $translation[0], $matches, PREG_SET_ORDER); + $s = ""; + 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"; + } + } + foreach($messages as $key => $val) { + $s .= "\t\t\t$key => '',\n"; + } + $file = substr_replace($file, $s, $translation[1], strlen($translation[0])); +} +file_put_contents("lang.inc.php", $file); diff --git a/auth.inc.php b/auth.inc.php index cdd19eb1..8131f20c 100644 --- a/auth.inc.php +++ b/auth.inc.php @@ -23,7 +23,7 @@ if (isset($_GET["logout"]) || !@mysql_connect($_GET["server"], $_SESSION["userna
- + "; } - echo '
:" maxlength="60" />
:" maxlength="16" />
:" maxlength="16" />
:
$val) { // expired session diff --git a/design.inc.php b/design.inc.php index f7179e25..7b3f2253 100644 --- a/design.inc.php +++ b/design.inc.php @@ -29,6 +29,7 @@ H2 { font-size: 150%; margin-top: 0; } ?> $valedit'; //! views can be unupdatable + echo '' . lang('edit') . ''; //! views can be unupdatable foreach ($childs as $child) { echo '