mirror of
https://github.com/friendica/friendica
synced 2025-04-28 01:50:13 +00:00
Merge pull request #11830 from MrPetovan/task/11826-pluralization
Use L10n->tt instead of t() for plural strings
This commit is contained in:
commit
e0ec304d2a
5 changed files with 151 additions and 121 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue