Skip to content

Commit 1810ff2

Browse files
committed
Use /lang dir for translations on Laravel 9.x
1 parent 72f30fa commit 1810ff2

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/Provider.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,22 @@ class Provider extends ServiceProvider
2323
*/
2424
public function boot(Router $router)
2525
{
26+
$langPath = 'vendor/firewall';
27+
28+
$langPath = (function_exists('lang_path'))
29+
? lang_path($langPath)
30+
: resource_path('lang/'.$langPath);
31+
2632
$this->publishes([
2733
__DIR__ . '/Config/firewall.php' => config_path('firewall.php'),
2834
__DIR__ . '/Migrations/2019_07_15_000000_create_firewall_ips_table.php' => database_path('migrations/2019_07_15_000000_create_firewall_ips_table.php'),
2935
__DIR__ . '/Migrations/2019_07_15_000000_create_firewall_logs_table.php' => database_path('migrations/2019_07_15_000000_create_firewall_logs_table.php'),
30-
__DIR__ . '/Resources/lang' => resource_path('lang/vendor/firewall'),
36+
__DIR__ . '/Resources/lang' => $langPath,
3137
], 'firewall');
3238

3339
$this->registerMiddleware($router);
3440
$this->registerListeners();
35-
$this->registerTranslations();
41+
$this->registerTranslations($langPath);
3642
$this->registerCommands();
3743
}
3844

@@ -91,15 +97,11 @@ public function registerListeners()
9197
*
9298
* @return void
9399
*/
94-
public function registerTranslations()
100+
public function registerTranslations($langPath)
95101
{
96-
$lang_path = resource_path('lang/vendor/firewall');
102+
$this->loadTranslationsFrom(__DIR__ . '/Resources/lang', 'firewall');
97103

98-
if (is_dir($lang_path)) {
99-
$this->loadTranslationsFrom($lang_path, 'firewall');
100-
} else {
101-
$this->loadTranslationsFrom(__DIR__ . '/Resources/lang', 'firewall');
102-
}
104+
$this->loadTranslationsFrom($langPath, 'firewall');
103105
}
104106

105107
public function registerCommands()

0 commit comments

Comments
 (0)