Laravel 拉威尔不会改变语言
Laravel没有改变我在controller中尝试过的语言Laravel 拉威尔不会改变语言,laravel,translation,Laravel,Translation,Laravel没有改变我在controller中尝试过的语言 if ($request->lang === 'English') { config(['app.locale' => 'en']); } else { config(['app.locale' => 'ar']); } 这个方法呢 App::setLocale('ar') \App::setLocale('ar') 还是这个方法
if ($request->lang === 'English') {
config(['app.locale' => 'en']);
} else {
config(['app.locale' => 'ar']);
}
这个方法呢
App::setLocale('ar')
\App::setLocale('ar')
还是这个方法
App::setLocale('ar')
\App::setLocale('ar')
我该怎么办?您可以创建一个中间件,将区域设置放在会话中并进行设置
php artisan make:middleware SetLocale
app\Http\Middleware\SetLocale.php
您是否在resources/lang/ar
下有语言文件?@jrcamatog是的,它在resources/lang/arDo下。请注意,区域设置仅会针对该特定请求而更改,而不会针对整个会话进行更改。@jrcamatog我希望整个项目的所有页面都使用它