mirror of
https://github.com/friendica/friendica
synced 2024-11-19 03:03:41 +00:00
Add support for additional interpolated variables in L10n->tt()
This commit is contained in:
parent
bbbbf8fd6b
commit
bff6a5a9ee
1 changed files with 5 additions and 2 deletions
|
@ -303,11 +303,12 @@ class L10n
|
||||||
* @param string $singular
|
* @param string $singular
|
||||||
* @param string $plural
|
* @param string $plural
|
||||||
* @param int $count
|
* @param int $count
|
||||||
|
* @param array $vars Variables to interpolate in the translation string
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @throws \Exception
|
* @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;
|
$s = null;
|
||||||
|
|
||||||
|
@ -340,7 +341,9 @@ class L10n
|
||||||
$s = $singular;
|
$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;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue