Laravel 5.8 setLocale globally

前端 未结 3 705
失恋的感觉
失恋的感觉 2021-01-03 09:31

I have a route:

    Route::get(\'/setlocale/{locale}\', function($locale) {
            App::setLocale($locale);

            


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-03 10:20

    I was facing the same problem, the locale was changing in session but not in config. So have checked the session's locale in every blade and controller and set the default the language instant from there, here is the code on my blade file

    @php
    
    if(\Session::get('locale') == 'en') 
        \App::setLocale('en');
    else                                
        \App::setLocale('bn');
    
    @endphp
    

    Hope it will help you

提交回复
热议问题