From 85b517ad10ad5abd0eef2c4f7d838cf7711e44ba Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 26 Apr 2022 11:06:00 +0200 Subject: [PATCH] Fix translations with trailing colons Signed-off-by: Joas Schilling --- lib/private/L10N/L10NString.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/private/L10N/L10NString.php b/lib/private/L10N/L10NString.php index 33ccc4b1409..73199fdbd1c 100644 --- a/lib/private/L10N/L10NString.php +++ b/lib/private/L10N/L10NString.php @@ -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); } -- 2.39.5