我正在尝试获取Laravel类LaravelLocalization::getCurrentLocale()
的方法,虽然我的默认语言环境是pt我总是得到en。我使用的包是. 我有的代码:boot()
AppServiceProvider
mcamara/laravel-localization
public function boot()
{
Schema::defaultStringLength(191);
// Twitter view share
$twitter = Twitter::getUserTimeline(['screen_name' => env('TWITTER_USER'), 'count' => 3, 'format' => 'object']);
view()->share('twitter', $twitter);
// Current language code view share
$language = LaravelLocalization::getCurrentLocale();
view()->share('lang', $language);
// Practice Areas
view()->share('practice_areas', \App\Models\PracticeArea::with('children')->orderBy('area_name')->where(['parent_id' => 0, 'language' => $language])->get());
}
我可能把它放在错误的地方,因为当我尝试共享practice_areas
变量时,即使切换语言,它也总是将其设置为en 。
我可能做错了什么?
提前感谢您的帮助