Browse Source
Add a check for the pipe character
Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/26375/head
Joas Schilling
5 years ago
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
2 changed files with
11 additions and
0 deletions
-
build/translation-checker.php
-
lib/private/L10N/L10NString.php
|
|
|
@ -48,6 +48,11 @@ foreach ($directories as $dir) { |
|
|
|
$content = file_get_contents($file->getPathname()); |
|
|
|
$json = json_decode($content, true); |
|
|
|
|
|
|
|
$translations = json_encode($json['translations']); |
|
|
|
if (strpos($content, '|') !== false) { |
|
|
|
$errors[] = $file->getPathname() . "\n" . ' ' . 'Contains a | in the translations' . "\n"; |
|
|
|
} |
|
|
|
|
|
|
|
if (json_last_error() !== JSON_ERROR_NONE) { |
|
|
|
$errors[] = $file->getPathname() . "\n" . ' ' . json_last_error_msg() . "\n"; |
|
|
|
} else { |
|
|
|
|
|
|
|
@ -59,6 +59,12 @@ class L10NString implements \JsonSerializable { |
|
|
|
|
|
|
|
public function __toString(): string { |
|
|
|
$translations = $this->l10n->getTranslations(); |
|
|
|
|
|
|
|
$pipeCheck = implode('', $translations[$this->text]); |
|
|
|
if (strpos($pipeCheck, '|') !== false) { |
|
|
|
return 'Can not use pipe character in translations'; |
|
|
|
} |
|
|
|
|
|
|
|
$identityTranslator = $this->l10n->getIdentityTranslator(); |
|
|
|
|
|
|
|
$parameters = $this->parameters; |
|
|
|
|