1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-23 09:32:29 +01:00
Pterodactyl-Panel/app/Http/Middleware/LanguageMiddleware.php
2019-09-05 21:32:57 -07:00

40 lines
834 B
PHP

<?php
namespace Pterodactyl\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Foundation\Application;
class LanguageMiddleware
{
/**
* @var \Illuminate\Foundation\Application
*/
private $app;
/**
* LanguageMiddleware constructor.
*
* @param \Illuminate\Foundation\Application $app
*/
public function __construct(Application $app)
{
$this->app = $app;
}
/**
* Handle an incoming request and set the user's preferred language.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
$this->app->setLocale($request->user()->language ?? config('app.locale', 'en'));
return $next($request);
}
}