|
|
@@ -85,7 +85,7 @@ class I18n
|
|
|
* @param mixed $args one or multiple parameters injected into placeholders
|
|
|
* @return string
|
|
|
*/
|
|
|
- public static function _($messageId)
|
|
|
+ public static function _($messageId, ...$args)
|
|
|
{
|
|
|
return forward_static_call_array('PrivateBin\I18n::translate', func_get_args());
|
|
|
}
|
|
|
@@ -99,7 +99,7 @@ class I18n
|
|
|
* @param mixed $args one or multiple parameters injected into placeholders
|
|
|
* @return string
|
|
|
*/
|
|
|
- public static function translate($messageId)
|
|
|
+ public static function translate($messageId, ...$args)
|
|
|
{
|
|
|
if (empty($messageId)) {
|
|
|
return $messageId;
|
|
|
@@ -114,7 +114,7 @@ class I18n
|
|
|
if (!array_key_exists($messageId, self::$_translations)) {
|
|
|
self::$_translations[$messageId] = $messages;
|
|
|
}
|
|
|
- $args = func_get_args();
|
|
|
+ array_unshift($args, $messageId);
|
|
|
if (is_array(self::$_translations[$messageId])) {
|
|
|
$number = (int) $args[1];
|
|
|
$key = self::_getPluralForm($number);
|
|
|
@@ -130,11 +130,9 @@ class I18n
|
|
|
}
|
|
|
// encode any non-integer arguments and the message ID, if it doesn't contain a link
|
|
|
$argsCount = count($args);
|
|
|
- if ($argsCount > 1) {
|
|
|
- for ($i = 0; $i < $argsCount; ++$i) {
|
|
|
- if (($i > 0 && !is_int($args[$i])) || strpos($args[0], '<a') === false) {
|
|
|
- $args[$i] = self::encode($args[$i]);
|
|
|
- }
|
|
|
+ for ($i = 0; $i < $argsCount; ++$i) {
|
|
|
+ if ($i > 0 ? !is_int($args[$i]) : strpos($args[0], '<a') === false) {
|
|
|
+ $args[$i] = self::encode($args[$i]);
|
|
|
}
|
|
|
}
|
|
|
return call_user_func_array('sprintf', $args);
|