Move string interpolation from __call() to get()

This commit is contained in:
Kijin Sung 2016-03-17 14:11:33 +09:00
parent 09eb7935fa
commit 014e7f13a4

View file

@ -176,7 +176,19 @@ class Lang
{
$args = func_get_args();
array_shift($args);
return $this->__call($key, $args);
if (count($args) === 1 && is_array($args[0]))
{
$args = $args[0];
}
// Get the translation.
$translation = $this->__get($key);
// If there are no arguments, return the translation.
if (!count($args)) return $translation;
// If there are arguments, interpolate them into the translation and return the result.
return vsprintf($translation, $args);
}
/**
@ -338,16 +350,6 @@ class Lang
*/
public function __call($key, $args = array())
{
// Remove a colon from the beginning of the string.
if ($key !== '' && $key[0] === ':') $key = substr($key, 1);
// Find the translation.
$translation = $this->__get($key);
// If there are no arguments, return the translation.
if (!count($args)) return $translation;
// If there are arguments, interpolate them into the translation and return the result.
return vsprintf($translation, $args);
return $this->get($key, $args);
}
}