Skip to content

Commit

Permalink
Merge pull request #1946 from alissn/FixTranslationDiscover
Browse files Browse the repository at this point in the history
Fix Translation Auto-Discovery for Enabled Modules
  • Loading branch information
dcblogdev authored Sep 17, 2024
2 parents 797c06b + 2789a91 commit 8bee9dc
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/LaravelModulesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,10 @@ protected function registerTranslations(): void
return;
}

$path = implode(DIRECTORY_SEPARATOR, [
$this->app['config']->get('modules.paths.modules'),
'*',
'lang',
]);

collect(glob($path, GLOB_ONLYDIR))
->each(function (string $path) use ($translator) {
preg_match('/\/([^\/]+)\/lang/', $path, $matches);
$translator->addNamespace(strtolower($matches[1]), $path);
collect(\Nwidart\Modules\Facades\Module::allEnabled())
->each(function (\Nwidart\Modules\Laravel\Module $module) use ($translator) {
$path = $module->getExtraPath($this->app['config']->get('modules.paths.generator.lang.path'));
$translator->addNamespace($module->getLowerName(), $path);
$translator->addJsonPath($path);
});
});
Expand Down

0 comments on commit 8bee9dc

Please sign in to comment.