Fix translations with trailing colons

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2022-04-26 11:06:00 +02:00
parent a4cd9fd37c
commit 26882a4b59
No known key found for this signature in database
GPG key ID: 7076EA9751AACDDA

View file

@ -74,10 +74,16 @@ class L10NString implements \JsonSerializable {
return 'Can not use pipe character in translations';
}
$beforeIdentity = $identity;
$identity = str_replace('%n', '%count%', $identity);
$parameters = [];
if ($beforeIdentity !== $identity) {
$parameters = ['%count%' => $this->count];
}
// $count as %count% as per \Symfony\Contracts\Translation\TranslatorInterface
$text = $identityTranslator->trans($identity, ['%count%' => $this->count]);
$text = $identityTranslator->trans($identity, $parameters);
return vsprintf($text, $this->parameters);
}