MYYA
这些方法在Illuminate/Foundation/helpers.php.在源码中可以看到,trans()helper 的定义如下: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); }}另外,正如您所说,__()助手是助手的别名trans():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); }}