lundi 14 décembre 2020

Change language on Middleware in Laravel

In this middleware I try to change the locale if a cookie is set , In my code I checked that the cookie its correct but the page language doesn't change

<?php

namespace App\Http\Middleware;

use Illuminate\Support\Facades\App;
use Session;

use Closure;

class ChangeLanguage
{
    public function handle($request, Closure $next)
    {
        if (isset($_COOKIE['language'])) {
            App::setLocale($_COOKIE['language']);
            Session::set('locale', $_COOKIE['language']);
        }

        return $next($request);
    }
}

I missed something?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire