blessing-skin-server/app/Http/Middleware/Internationalization.php

27 lines
555 B
PHP
Raw Normal View History

<?php
namespace App\Http\Middleware;
use App;
use Cookie;
2016-09-15 09:20:02 +08:00
use Session;
use Illuminate\Support\Arr;
class Internationalization
{
public function handle($request, \Closure $next)
{
// Load from cookie
if (Cookie::has('locale')) {
session(['locale' => Cookie::get('locale')]);
}
if (Session::has('locale') && Arr::exists(config('locales'), session('locale'))) {
// Set app locale dynamically
App::setLocale(session('locale'));
}
return $next($request);
}
}