![59434471f0bddb8a7dc07cfd089b151d.png](https://img-blog.csdnimg.cn/img_convert/59434471f0bddb8a7dc07cfd089b151d.png)
这篇文章是记录
Laravel
项目语言包Laravel lang拓展包的安装过程及遇到的问题,这个拓展包应该是常用的,所以记录起来以便查看,这里以中文语言为例。
一、在项目根目录下使用composer
进行安装拓展包
composer require "overtrue/laravel-lang:~3.0"
二、修改config/app.php
配置文件
将IlluminateTranslationTranslationServiceProvider::class,
替换为 OvertrueLaravelLangTranslationServiceProvider::class,
然后将 'locale' => 'en', 修改成 'locale' => 'zh-CN',
三、修改扩展包提供的语言文件,使用以下命令发布语言文件到项目里
php artisan lang:publish zh-CN
一般情况下到这里就可以了,但如果报了以下错误
There are no commands defined in the "lang" namespace.
那么你需要执行命令来清楚缓存
php artisan config:cache
之后在重新执行命令发布语言文件
php artisan lang:publish zh-CN