2016-01-21 03:39:02 +00:00
|
|
|
<?php
|
2016-12-07 22:46:38 +00:00
|
|
|
|
2016-01-21 03:39:02 +00:00
|
|
|
namespace Pterodactyl\Http\Middleware;
|
|
|
|
|
2017-10-29 17:37:25 +00:00
|
|
|
use Illuminate\Http\Request;
|
2017-11-03 23:16:49 +00:00
|
|
|
use Illuminate\Foundation\Application;
|
2016-01-21 03:39:02 +00:00
|
|
|
|
|
|
|
class LanguageMiddleware
|
|
|
|
{
|
2017-10-29 17:37:25 +00:00
|
|
|
/**
|
|
|
|
* LanguageMiddleware constructor.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function __construct(private Application $app)
|
2017-10-29 17:37:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-21 03:39:02 +00:00
|
|
|
/**
|
2018-09-03 22:17:53 +00:00
|
|
|
* Handle an incoming request and set the user's preferred language.
|
2016-01-21 03:39:02 +00:00
|
|
|
*/
|
2022-11-29 17:53:59 +00:00
|
|
|
public function handle(Request $request, \Closure $next): mixed
|
2016-01-21 03:39:02 +00:00
|
|
|
{
|
2018-09-03 22:17:53 +00:00
|
|
|
$this->app->setLocale($request->user()->language ?? config('app.locale', 'en'));
|
2016-12-07 22:46:38 +00:00
|
|
|
|
2016-01-21 03:39:02 +00:00
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|