]> git.mxchange.org Git - friendica.git/commitdiff
Add support for additional interpolated variables in L10n->tt()
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 8 Aug 2022 05:51:42 +0000 (01:51 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 8 Aug 2022 05:51:42 +0000 (01:51 -0400)
src/Core/L10n.php

index 2c45fb95519f47473e7ce867b0881e4758c69423..db7ccbd2c65f24d145409c97625b354c64d06b52 100644 (file)
@@ -303,11 +303,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;
 
@@ -340,7 +341,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;
        }