mirror of
https://github.com/pterodactyl/panel.git
synced 2024-11-23 09:32:29 +01:00
36 lines
696 B
PHP
36 lines
696 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.
|
|
*/
|
|
public function __construct(Application $app)
|
|
{
|
|
$this->app = $app;
|
|
}
|
|
|
|
/**
|
|
* Handle an incoming request and set the user's preferred language.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle(Request $request, Closure $next)
|
|
{
|
|
$this->app->setLocale($request->user()->language ?? config('app.locale', 'en'));
|
|
|
|
return $next($request);
|
|
}
|
|
}
|