-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible [Bug]: Wrong value returned while retrieving lines from language file #43
Comments
Yes, it is just how this line of code works https://github.com/laravel/framework/blob/master/src/Illuminate/Translation/Translator.php#L98 public function get($key, $parameters = array(), $locale = null)
{
list($namespace, $group, $item) = $this->parseKey($key);
// Once we call the "load" method, we will receive back the "domain" for the
// namespace and group. The "domain" is used by the Symfony translator to
// logically separate related groups of messages, and should be unique.
$domain = $this->load($group, $namespace, $locale);
$line = $this->trans->trans($item, $parameters, $domain, $locale);
return $line == $item ? $key : $line;
} I think it will be better to just return the $line without the conditional statement. For example when simply returning the $line variable: trans('test.rabbit') when not having the key still returns "rabbit" as default without the key. I don't find any importance of returning the full $key string if the array key is not available. Instead we can return the $line. @taylorotwell will know the reason behind that conditional statement. |
Setup fractal and an example transformer
Check error_reporting before throwing ErrorException
I just noticed that when 'key' and 'value' are the same in language files, the Lang class returns the key instead of the existing value.
Line in Language file (/app/lang/en/test.php):
Retrieving the line:
Result:
As if the language key doesn't exists.
The text was updated successfully, but these errors were encountered: