1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-09 16:17:48 +02:00

Lang: Display line of the update

This commit is contained in:
Jakub Vrana
2025-04-10 19:04:06 +02:00
parent 6819815b88
commit b30526213d

View File

@@ -47,7 +47,8 @@ foreach (glob(__DIR__ . "/adminer/lang/" . ($_SESSION["lang"] ?: "*") . ".inc.ph
function update_translations($lang, $messages, $filename, $pattern, $tabs = "\t") { function update_translations($lang, $messages, $filename, $pattern, $tabs = "\t") {
$file = file_get_contents($filename); $file = file_get_contents($filename);
$file = str_replace("\r", "", $file); $file = str_replace("\r", "", $file);
$s = preg_replace_callback($pattern, function ($match) use ($lang, $messages, $filename, $file, $tabs) { $start = 0;
$s = preg_replace_callback($pattern, function ($match) use ($lang, $messages, $filename, $file, $tabs, &$start) {
$prefix = $match[1][0]; $prefix = $match[1][0];
$start = $match[2][1]; $start = $match[2][1];
preg_match_all("~^(\\s*(?:// [^'].*\\s+)?)(?:// )?(('(?:[^\\\\']+|\\\\.)*') => (.*[^,\n])),?~m", $match[2][0], $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); preg_match_all("~^(\\s*(?:// [^'].*\\s+)?)(?:// )?(('(?:[^\\\\']+|\\\\.)*') => (.*[^,\n])),?~m", $match[2][0], $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
@@ -75,6 +76,7 @@ function update_translations($lang, $messages, $filename, $pattern, $tabs = "\t"
} }
} }
if ($messages) { if ($messages) {
$start += strlen($s);
foreach ($messages as $idf => $val) { foreach ($messages as $idf => $val) {
// add new messages // add new messages
if ($val == "," && strpos($idf, "%d")) { if ($val == "," && strpos($idf, "%d")) {
@@ -89,6 +91,6 @@ function update_translations($lang, $messages, $filename, $pattern, $tabs = "\t"
if ($s != $file) { if ($s != $file) {
$s = str_replace("array(\n\t\t\t'' => null,\n\t\t),", "array('' => null),", $s); $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:" . (substr_count($s, "\n", 0, $start) + 1) . ":Updated.\n";
} }
} }