cbcf62086f
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
27 lines
574 B
PHP
27 lines
574 B
PHP
<?php
|
|
|
|
namespace Pterodactyl\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Foundation\Application;
|
|
|
|
class LanguageMiddleware
|
|
{
|
|
/**
|
|
* LanguageMiddleware constructor.
|
|
*/
|
|
public function __construct(private Application $app)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Handle an incoming request and set the user's preferred language.
|
|
*/
|
|
public function handle(Request $request, Closure $next): mixed
|
|
{
|
|
$this->app->setLocale($request->user()->language ?? config('app.locale', 'en'));
|
|
|
|
return $next($request);
|
|
}
|
|
}
|