diff options
author | Joas Schilling <coding@schilljs.com> | 2021-03-30 21:04:41 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-04-20 16:42:04 +0200 |
commit | 439457d2b4cdc511fbce826764b2b27e30abee50 (patch) | |
tree | b97654d2a21850f185406488aa5b30c0fb8f2c35 /lib/private/L10N | |
parent | a4c6749b020d5cb4e63a54b0aa9ca5ebe961ee4d (diff) | |
download | nextcloud-server-439457d2b4cdc511fbce826764b2b27e30abee50.tar.gz nextcloud-server-439457d2b4cdc511fbce826764b2b27e30abee50.zip |
Fix languages that miss a string in the translation
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/L10N')
-rw-r--r-- | lib/private/L10N/L10NString.php | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/private/L10N/L10NString.php b/lib/private/L10N/L10NString.php index ae90f52a02d..ef33babac5a 100644 --- a/lib/private/L10N/L10NString.php +++ b/lib/private/L10N/L10NString.php @@ -59,12 +59,6 @@ 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; @@ -72,7 +66,22 @@ class L10NString implements \JsonSerializable { $parameters['%count%'] = $this->count; // Use the indexed version as per \Symfony\Contracts\Translation\TranslatorInterface - $identity = implode('|', $translations[$this->text]); + $identity = $this->text; + if (array_key_exists($this->text, $translations)) { + $identity = $translations[$this->text]; + } + + if (is_array($identity)) { + $pipeCheck = implode('', $identity); + if (strpos($pipeCheck, '|') !== false) { + return 'Can not use pipe character in translations'; + } + + $identity = implode('|', $identity); + } else if (strpos($identity, '|') !== false) { + return 'Can not use pipe character in translations'; + } + $identity = str_replace('%n', '%count%', $identity); return $identityTranslator->trans($identity, $parameters); |