php - Where to find defined language functions in Laravel?
Solution:
vendor/laravel/framework/src/Illuminate/Foundation/helpers.php
Answer
Solution:
Those methods are defined in the .
As you can see in the source code, the helper is defined as follows:
if (! function_exists('trans')) {
/**
* Translate the given message.
*
* @param string|null $key
* @param array $replace
* @param string|null $locale
* @return \Illuminate\Contracts\Translation\Translator|string|array|null
*/
function trans($key = null, $replace = [], $locale = null)
{
if (is_null($key)) {
return app('translator');
}
return app('translator')->get($key, $replace, $locale);
}
}
Also, as you said, the helper is an alias for the
trans()
helper:
if (! function_exists('__')) {
/**
* Translate the given message.
*
* @param string|null $key
* @param array $replace
* @param string|null $locale
* @return string|array|null
*/
function __($key = null, $replace = [], $locale = null)
{
if (is_null($key)) {
return $key;
}
return trans($key, $replace, $locale);
}
}
Source