Laravel : App::setLocale doesn’t work

Tags: , , ,



I’m using laravel 5.1, I’m trying to update locale in app file like this : In Locale Middleware file :

...
public function handle($request, Closure $next)
    {       
        if(Session::has('locale'))
        {
            $lang = Session::get('locale');            
            App::setLocale($lang);        
        }

        return $next($request);
    }

Any idea about this ??

Answer

Oooof finally after two hours ><‘ !! It’s the line place of locale class in middleware -.-‘ !!! I set it in last line like this :

    ...
    ...
    AppHttpMiddlewareVerifyCsrfToken::class,
        AppHttpMiddlewareLocale::class,        
    ];

and All is fine and working ! thanks for you all :))))



Source: stackoverflow