From 38bdd0a961af6b7f5b713bfa63aeb5bd48303144 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Mon, 7 Apr 2025 18:22:59 +0200 Subject: [PATCH] lang.php: Add translation of plugin description --- lang.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lang.php b/lang.php index 0bdda746..388dbc6b 100755 --- a/lang.php +++ b/lang.php @@ -22,7 +22,7 @@ foreach ( ) as $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]); } } @@ -33,8 +33,9 @@ foreach (glob(__DIR__ . "/adminer/lang/" . ($_SESSION["lang"] ?: "*") . ".inc.ph if ($lang != "xx") { foreach (glob(__DIR__ . "/plugins/*.php") as $filename) { $file = file_get_contents($filename); - if (preg_match_all("~\\\$this->lang\\(('(?:[^\\\\']+|\\\\.)*')([),])~", $file, $matches)) { - $messages = array_combine($matches[1], $matches[2]); + if (preg_match('~extends Adminer\\\\Plugin~', $file)) { + 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_put_contents($filename, $file); 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; }, $file, -1, $count, PREG_OFFSET_CAPTURE); if ($s != $file) { + $s = str_replace("array(\n\t\t\t'' => null,\n\t\t),", "array('' => null),", $s); file_put_contents($filename, $s); echo "$filename updated.\n"; }