Add debug flag to the translation checker

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2022-06-07 17:09:46 +02:00
parent 21734fdda4
commit a33310f1b1
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
1 changed files with 13 additions and 1 deletions

View File

@ -23,6 +23,8 @@ $directories = [
__DIR__ . '/../core/l10n',
];
$isDebug = in_array('--debug', $argv, true) || in_array('-d', $argv, true);
$apps = new \DirectoryIterator(__DIR__ . '/../apps');
foreach ($apps as $app) {
if (!file_exists($app->getPathname() . '/l10n')) {
@ -50,7 +52,7 @@ foreach ($directories as $dir) {
$translations = json_encode($json['translations']);
if (strpos($translations, '|') !== false) {
$errors[] = $file->getPathname() . "\n" . ' ' . 'Contains a | in the translations' . "\n";
$errors[] = $file->getPathname() . "\n" . ' ' . 'Contains a | in the translations.' . "\n";
}
if (json_last_error() !== JSON_ERROR_NONE) {
@ -58,6 +60,16 @@ foreach ($directories as $dir) {
} else {
$valid++;
}
if ($isDebug && $file->getFilename() === 'en_GB.json') {
$sourceStrings = json_encode(array_keys($json['translations']));
if (strpos($sourceStrings, '\u2019') !== false) {
$errors[] = $file->getPathname() . "\n"
. ' ' . 'Contains a unicode single quote "" in the english source string, please replace with normal single quotes.' . "\n"
. ' ' . 'Please note that this only updates after a sync to transifex.' . "\n";
}
}
}
}