You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
686 B
26 lines
686 B
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
use Illuminate\Support\Facades\App;
|
|
use Closure;
|
|
|
|
class LocalizationMiddleware
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
// Check header request and determine localizaton
|
|
$local = ($request->hasHeader('X-localization')) ? (strlen($request->header('X-localization'))>0?$request->header('X-localization'): 'en'): 'en';
|
|
|
|
// set laravel localization
|
|
App::setLocale($local);
|
|
// continue request
|
|
return $next($request);
|
|
}
|
|
}
|
|
|