From 21eb62c1556cabf7bebcb25defc9f2da8a8e5094 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Tue, 22 Oct 2024 13:03:06 +0200 Subject: [PATCH 1/2] build: Print RTL limited characters in translation-checker Signed-off-by: provokateurin --- build/translation-checker.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/translation-checker.php b/build/translation-checker.php index b6d947ecbf091..6f131336ef3df 100644 --- a/build/translation-checker.php +++ b/build/translation-checker.php @@ -77,8 +77,8 @@ $content = file_get_contents($file->getPathname()); $language = pathinfo($file->getFilename(), PATHINFO_FILENAME); - if (!in_array($language, $rtlLanguages, true) && preg_match('/[' . implode('', $rtlCharacters) . ']/u', $content)) { - $errors[] = $file->getPathname() . "\n" . ' ' . 'Contains a RTL limited character in the translations.' . "\n"; + if (!in_array($language, $rtlLanguages, true) && preg_match('/[' . implode('', $rtlCharacters) . ']/u', $content, $matches)) { + $errors[] = $file->getPathname() . "\n" . ' ' . 'Contains a RTL limited characters in the translations. Offending Unicode codepoints: ' . implode(', ', array_map(static fn (string $match) => mb_ord($match), $matches)) . "\n"; } $json = json_decode($content, true); From ff2f346579e21c4f409d82b889bed8189355e9f3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 23 Oct 2024 09:39:57 +0200 Subject: [PATCH 2/2] build: Show the actual string Signed-off-by: Joas Schilling --- build/translation-checker.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/translation-checker.php b/build/translation-checker.php index 6f131336ef3df..6676a49caa8b0 100644 --- a/build/translation-checker.php +++ b/build/translation-checker.php @@ -77,8 +77,8 @@ $content = file_get_contents($file->getPathname()); $language = pathinfo($file->getFilename(), PATHINFO_FILENAME); - if (!in_array($language, $rtlLanguages, true) && preg_match('/[' . implode('', $rtlCharacters) . ']/u', $content, $matches)) { - $errors[] = $file->getPathname() . "\n" . ' ' . 'Contains a RTL limited characters in the translations. Offending Unicode codepoints: ' . implode(', ', array_map(static fn (string $match) => mb_ord($match), $matches)) . "\n"; + if (!in_array($language, $rtlLanguages, true) && preg_match_all('/^(.+[' . implode('', $rtlCharacters) . '].+)$/mu', $content, $matches)) { + $errors[] = $file->getPathname() . "\n" . ' ' . 'Contains a RTL limited characters in the translations. Offending strings:' . "\n" . implode("\n", $matches[0]) . "\n"; } $json = json_decode($content, true);