From f660e4c09fd99805997ce37b265375dd702c9348 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 9422f7e5dcb59..86646ac47ca5f 100644 --- a/build/translation-checker.php +++ b/build/translation-checker.php @@ -76,8 +76,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 61e3fa054de4e5df58bc8825dd7c1493cd25fb14 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 86646ac47ca5f..6b820bea1909e 100644 --- a/build/translation-checker.php +++ b/build/translation-checker.php @@ -76,8 +76,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);