mirror of
https://github.com/vrana/adminer.git
synced 2025-08-13 01:54:00 +02:00
lang.php: Add translation of plugin description
This commit is contained in:
8
lang.php
8
lang.php
@@ -22,7 +22,7 @@ foreach (
|
|||||||
) as $include
|
) as $include
|
||||||
) {
|
) {
|
||||||
$file = file_get_contents($include);
|
$file = file_get_contents($include);
|
||||||
if (preg_match_all("~lang\\(('(?:[^\\\\']+|\\\\.)*')([),])~", $file, $matches)) { // lang() always uses apostrophes
|
if (preg_match_all("~[^>]lang\\(('(?:[^\\\\']+|\\\\.)*')([),])~", $file, $matches)) { // lang() always uses apostrophes
|
||||||
$messages_all += array_combine($matches[1], $matches[2]);
|
$messages_all += array_combine($matches[1], $matches[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,8 +33,9 @@ foreach (glob(__DIR__ . "/adminer/lang/" . ($_SESSION["lang"] ?: "*") . ".inc.ph
|
|||||||
if ($lang != "xx") {
|
if ($lang != "xx") {
|
||||||
foreach (glob(__DIR__ . "/plugins/*.php") as $filename) {
|
foreach (glob(__DIR__ . "/plugins/*.php") as $filename) {
|
||||||
$file = file_get_contents($filename);
|
$file = file_get_contents($filename);
|
||||||
if (preg_match_all("~\\\$this->lang\\(('(?:[^\\\\']+|\\\\.)*')([),])~", $file, $matches)) {
|
if (preg_match('~extends Adminer\\\\Plugin~', $file)) {
|
||||||
$messages = array_combine($matches[1], $matches[2]);
|
preg_match_all("~\\\$this->lang\\(('(?:[^\\\\']+|\\\\.)*')([),])~", $file, $matches);
|
||||||
|
$messages = array("''" => "") + array_combine($matches[1], $matches[2]);
|
||||||
$file = preg_replace("~(static \\\$translations = array\\((?!.*'$lang').*?)\t\\);~s", "\\1\t\t'$lang' => array(\n\t\t),\n\t);", $file);
|
$file = preg_replace("~(static \\\$translations = array\\((?!.*'$lang').*?)\t\\);~s", "\\1\t\t'$lang' => array(\n\t\t),\n\t);", $file);
|
||||||
file_put_contents($filename, $file);
|
file_put_contents($filename, $file);
|
||||||
update_translations($lang, $messages, $filename, "~(static \\\$translations = array\\(.*'$lang' => array\\(\n)(.*)(?=^\t\t\\),)~msU", "\t\t\t");
|
update_translations($lang, $messages, $filename, "~(static \\\$translations = array\\(.*'$lang' => array\\(\n)(.*)(?=^\t\t\\),)~msU", "\t\t\t");
|
||||||
@@ -86,6 +87,7 @@ function update_translations($lang, $messages, $filename, $pattern, $tabs = "\t"
|
|||||||
return $prefix . $s;
|
return $prefix . $s;
|
||||||
}, $file, -1, $count, PREG_OFFSET_CAPTURE);
|
}, $file, -1, $count, PREG_OFFSET_CAPTURE);
|
||||||
if ($s != $file) {
|
if ($s != $file) {
|
||||||
|
$s = str_replace("array(\n\t\t\t'' => null,\n\t\t),", "array('' => null),", $s);
|
||||||
file_put_contents($filename, $s);
|
file_put_contents($filename, $s);
|
||||||
echo "$filename updated.\n";
|
echo "$filename updated.\n";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user