Merge pull request #11830 from MrPetovan/task/11826-pluralization

Use L10n->tt instead of t() for plural strings
This commit is contained in:
Philipp 2022-08-08 15:35:54 +02:00 committed by GitHub
commit e0ec304d2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 151 additions and 121 deletions

View file

@ -304,11 +304,12 @@ class L10n
* @param string $singular
* @param string $plural
* @param int $count
* @param array $vars Variables to interpolate in the translation string
*
* @return string
* @throws \Exception
*/
public function tt(string $singular, string $plural, int $count): string
public function tt(string $singular, string $plural, int $count, ...$vars): string
{
$s = null;
@ -341,7 +342,9 @@ class L10n
$s = $singular;
}
$s = @sprintf($s, $count);
// We mute errors here because the translation strings may not be referencing the count at all,
// but we still have to try the interpolation just in case it is indeed referenced.
$s = @sprintf($s, $count, ...$vars);
return $s;
}