Hey Michel,
Of course, it's possible and the principle is the same as in any other Laravel application.
For example, if you keep the selected language in the session, then you can simply create a middleware that will run on every request and update the app locale. Here is an example middleware that you can use as a guideline for implementing this:
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Carbon;
class SetLocale
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// get locale from the session or default to "en"
$locale = session()->get('locale', 'en');
app()->setLocale($locale);
Carbon::setLocale($locale);
return $next($request);
}
}
Of course, you will need to add this middleware to the "web" middleware group in the "app/Http/Kernel.php" file so it can run on every request.
Hey Michel,
Of course, it's possible and the principle is the same as in any other Laravel application.
For example, if you keep the selected language in the session, then you can simply create a middleware that will run on every request and update the app locale. Here is an example middleware that you can use as a guideline for implementing this:
Of course, you will need to add this middleware to the "web" middleware group in the "app/Http/Kernel.php" file so it can run on every request.