mirror of
https://github.com/nextcloud/server.git
synced 2026-02-13 15:54:59 -05:00
Merge pull request #32159 from nextcloud/backport/32155/stable24
[stable24] Fx translations with trailing colon
This commit is contained in:
commit
5b4df735ec
2 changed files with 14 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,13 @@ class L10nTest extends TestCase {
|
|||
return new Factory($config, $request, $userSession, \OC::$SERVERROOT);
|
||||
}
|
||||
|
||||
public function testSimpleTranslationWithTrailingColon(): void {
|
||||
$transFile = \OC::$SERVERROOT.'/tests/data/l10n/de.json';
|
||||
$l = new L10N($this->getFactory(), 'test', 'de', 'de_AT', [$transFile]);
|
||||
|
||||
$this->assertEquals('Files:', $l->t('Files:'));
|
||||
}
|
||||
|
||||
public function testGermanPluralTranslations() {
|
||||
$transFile = \OC::$SERVERROOT.'/tests/data/l10n/de.json';
|
||||
$l = new L10N($this->getFactory(), 'test', 'de', 'de_AT', [$transFile]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue