Laravel 8 Translations
2021-07-19 10:58 更新
如果你的扩展包中包含 语言包文件 ,你需要使用 loadTranslationsFrom 方法告知 Laravel 如何加载它们。例如,如果你的扩展包名为 courier,你需要将下面的内容加入到服务提供者的 boot 方法中:
/**
* 启动应用服务
*
* @return void
*/
public function boot()
{
$this->loadTranslationsFrom(__DIR__.'/path/to/translations', 'courier');
} 扩展包翻译约定使用 package::file.line 语法进行引用。因此,你可以按照下面的方式来加载 courier 扩展包中的 messages 文件的 welcome 行:
echo trans('courier::messages.welcome'); echo trans('courier::messages.welcome'); 以上内容是否对您有帮助:

免费 AI IDE


更多建议: