Skip to content

Commit 9a06647

Browse files
committed
Added support for user specific languages
1 parent 7cf79a1 commit 9a06647

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ APP_TIMEZONE=America/New_York
66
APP_CLEAR_TASKLOG=720
77
APP_DELETE_MINUTES=10
88
APP_ENVIRONMENT_ONLY=true
9+
LANG_MUST_BE_GLOBAL=false
910

1011
DB_HOST=127.0.0.1
1112
DB_PORT=3306
@@ -26,4 +27,4 @@ MAIL_FROM=no-reply@example.com
2627

2728
QUEUE_HIGH=high
2829
QUEUE_STANDARD=standard
29-
QUEUE_LOW=low
30+
QUEUE_LOW=low

app/Http/Middleware/LanguageMiddleware.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Illuminate\Http\Request;
1414
use Illuminate\Foundation\Application;
1515
use Illuminate\Contracts\Config\Repository;
16+
use Illuminate\Support\Facades\Auth;
1617

1718
class LanguageMiddleware
1819
{
@@ -47,7 +48,11 @@ public function __construct(Application $app, Repository $config)
4748
*/
4849
public function handle(Request $request, Closure $next)
4950
{
50-
$this->app->setLocale($this->config->get('app.locale', 'en'));
51+
if (!Auth::check() || $this->config->get('pterodactyl.lang.global')) {
52+
$this->app->setLocale($this->config->get('app.locale', 'en'));
53+
} else {
54+
$this->app->setLocale(Auth::user()->language);
55+
}
5156

5257
return $next($request);
5358
}

config/pterodactyl.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
*/
162162
'lang' => [
163163
'in_context' => env('PHRASE_IN_CONTEXT', false),
164+
'global' => env('LANG_MUST_BE_GLOBAL', false),
164165
],
165166

166167
/*

0 commit comments

Comments
 (0)