Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Http/Middleware/LanguageMiddleware.php
10279 views
1
<?php
2
3
namespace Pterodactyl\Http\Middleware;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Foundation\Application;
7
8
class LanguageMiddleware
9
{
10
/**
11
* LanguageMiddleware constructor.
12
*/
13
public function __construct(private Application $app)
14
{
15
}
16
17
/**
18
* Handle an incoming request and set the user's preferred language.
19
*/
20
public function handle(Request $request, \Closure $next): mixed
21
{
22
$this->app->setLocale($request->user()->language ?? config('app.locale', 'en'));
23
24
return $next($request);
25
}
26
}
27
28