From a1c3e34e0474eb7250d6cd9f7735fa7b79290fec Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Sat, 8 Mar 2025 17:06:30 +0100 Subject: [PATCH] Translations: check fullstops in 'ja' and 'he' --- adminer/lang/he.inc.php | 2 +- lang.php | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/adminer/lang/he.inc.php b/adminer/lang/he.inc.php index d5440556..dd4491a1 100644 --- a/adminer/lang/he.inc.php +++ b/adminer/lang/he.inc.php @@ -280,7 +280,7 @@ $translations = array( 'Default value' => 'ערך ברירת מחדל', 'Full table scan' => 'סריקה טבלה מלאה', 'Too many unsuccessful logins, try again in %d minute(s).' => 'יותר מידי נסיונות כניסה נכשלו, אנא נסה עוד %d דקות', - 'Thanks for using Adminer, consider donating.' => 'תודה שהשתמש ב-adminer אנא שקול לתרום.', + 'Thanks for using Adminer, consider donating.' => 'תודה שהשתמש ב-adminer אנא שקול לתרום', 'Master password expired. Implement %s method to make it permanent.' => 'סיסמת המאסטר פגה התקן תוסף על מנת להפוך את זה לתמידי', 'If you did not send this request from Adminer then close this page.' => 'אם לא אתה שלחת בקשה ל-Adminer הינך יכול לסגור חלון זה', 'You can upload a big SQL file via FTP and import it from server.' => 'ניתן לעלות קבצים ב-FTP ואז למשוך אותם מהשרת', diff --git a/lang.php b/lang.php index 7c7e1d7b..a4a7adc4 100755 --- a/lang.php +++ b/lang.php @@ -35,15 +35,19 @@ foreach (glob(__DIR__ . "/adminer/lang/" . ($_SESSION["lang"] ?: "*") . ".inc.ph preg_match_all("~^(\\s*(?:// [^'].*\\s+)?)(?:// )?(('(?:[^\\\\']+|\\\\.)*') => (.*[^,\n])),?~m", $file, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); $s = ""; $lang = basename($filename, ".inc.php"); - $fullstop = ($lang == "bn" ? '।' : (substr($lang, 0, 2) == 'zh' ? '。' : ($lang == 'he' || $lang == 'ja' ? '' : '\.'))); + $fullstop = ($lang == "bn" ? '।' : (preg_match('~^(ja|zh)~', $lang) ? '。' : ($lang == 'he' ? '[^.]' : '\.'))); foreach ($matches as $match) { list(, list($indent), list($line, $offset), list($en), list($translation)) = $match; if (isset($messages[$en])) { // keep current messages $s .= "$indent$line,\n"; unset($messages[$en]); - if ($en != "','" && $fullstop && (substr($en, -2, 1) == "." xor preg_match("~$fullstop'\)?\$~", $line))) { - echo "$filename:" . (substr_count($file, "\n", 0, $offset) + 1) . ":Not matching fullstop: $line\n"; + $en_fullstop = (substr($en, -2, 1) == "."); + //! check in array + if ($en != "','" && ($en_fullstop xor preg_match("~($fullstop)'\)?\$~", $line, $match))) { + if ($lang != ($en_fullstop ? "ja" : "he")) { // fullstop is optional in 'ja', forbidden in 'he' + echo "$filename:" . (substr_count($file, "\n", 0, $offset) + 1) . ":Not matching fullstop: $line\n"; + } } if (preg_match('~%~', $en) xor preg_match('~%~', $translation)) { echo "$filename:" . (substr_count($file, "\n", 0, $offset) + 1) . ":Not matching placeholder.\n"; @@ -54,14 +58,14 @@ foreach (glob(__DIR__ . "/adminer/lang/" . ($_SESSION["lang"] ?: "*") . ".inc.ph } } if ($messages) { - if (basename($filename) != "en.inc.php") { + if ($lang != "en") { $s .= "\n"; } foreach ($messages as $idf => $val) { // add new messages if ($val == "," && strpos($idf, "%d")) { $s .= "\t$idf => array(),\n"; - } elseif (basename($filename) != "en.inc.php") { + } elseif ($lang != "en") { $s .= "\t$idf => null,\n"; } }