aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2024-09-24 12:14:29 +0200
committerGitHub <noreply@github.com>2024-09-24 12:14:29 +0200
commit79dd81995f70f71a5ba2e19957d9261e3a6030b3 (patch)
tree660046a1e29392539cf6d087958d3ffbca691990
parent6fab716cafc1ff6f918de6c00d9a025e8028d9cd (diff)
parentbff5d572af1b580331b3be3611a238ab129052cd (diff)
downloadnextcloud-server-79dd81995f70f71a5ba2e19957d9261e3a6030b3.tar.gz
nextcloud-server-79dd81995f70f71a5ba2e19957d9261e3a6030b3.zip
Merge pull request #48308 from nextcloud/backport/47349/stable30
[stable30] Add bidirectional text support - Backend
-rw-r--r--build/translation-checker.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/build/translation-checker.php b/build/translation-checker.php
index 399031c12ae..b6d947ecbf0 100644
--- a/build/translation-checker.php
+++ b/build/translation-checker.php
@@ -16,6 +16,35 @@ $untranslatedApps = [
'testing',
];
+// Next line only looks messed up, but it works. Don't touch it!
+$rtlCharacters = [
+ '\x{061C}', // ARABIC LETTER MARK
+ '\x{0623}', // ARABIC LETTER ALEF WITH HAMZA ABOVE
+ '\x{200E}', // LEFT-TO-RIGHT MARK
+ '\x{200F}', // RIGHT-TO-LEFT MARK
+ '\x{202A}', // LEFT-TO-RIGHT EMBEDDING
+ '\x{202B}', // RIGHT-TO-LEFT EMBEDDING
+ '\x{202C}', // POP DIRECTIONAL FORMATTING
+ '\x{202D}', // LEFT-TO-RIGHT OVERRIDE
+ '\x{202E}', // RIGHT-TO-LEFT OVERRIDE
+ '\x{2066}', // LEFT-TO-RIGHT ISOLATE
+ '\x{2067}', // RIGHT-TO-LEFT ISOLATE
+ '\x{2068}', // FIRST STRONG ISOLATE
+ '\x{2069}', // POP DIRECTIONAL ISOLATE
+ '\x{206C}', // INHIBIT ARABIC FORM SHAPING
+ '\x{206D}', // ACTIVATE ARABIC FORM SHAPING
+];
+
+$rtlLanguages = [
+ 'ar', // Arabic
+ 'fa', // Persian
+ 'he', // Hebrew
+ 'ps', // Pashto,
+ 'ug', // 'Uyghurche / Uyghur
+ 'ur_PK', // Urdu
+ 'uz', // Uzbek Afghan
+];
+
$valid = 0;
$errors = [];
$apps = new \DirectoryIterator(__DIR__ . '/../apps');
@@ -46,6 +75,12 @@ foreach ($directories as $dir) {
}
$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";
+ }
+
$json = json_decode($content, true);
$translations = json_encode($json['translations']);