Skip to content

Commit

Permalink
Merge pull request #48308 from nextcloud/backport/47349/stable30
Browse files Browse the repository at this point in the history
[stable30] Add bidirectional text support - Backend
  • Loading branch information
nickvergessen authored Sep 24, 2024
2 parents 6fab716 + bff5d57 commit 79dd819
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions build/translation-checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,35 @@
'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');
Expand Down Expand Up @@ -46,6 +75,12 @@
}

$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']);
Expand Down

0 comments on commit 79dd819

Please sign in to comment.