misc_pterodactyl-panel/app/Http/Middleware/LanguageMiddleware.php

27 lines
562 B
PHP
Raw Normal View History

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.
*/
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
*/
2023-02-23 19:30:16 +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);
}
}