blessing-skin-server/app/Http/Middleware/Internationalization.php
2016-12-30 12:43:59 +08:00

29 lines
581 B
PHP

<?php
namespace App\Http\Middleware;
use App;
use Cookie;
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')) {
// Set app locale dynamically
App::setLocale(session('locale'));
} else {
App::setLocale($request->getPreferredLanguage());
}
return $next($request);
}
}