Skip to content

Commit 8bee9dc

Browse files
authored
Merge pull request #1946 from alissn/FixTranslationDiscover
Fix Translation Auto-Discovery for Enabled Modules
2 parents 797c06b + 2789a91 commit 8bee9dc

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/LaravelModulesServiceProvider.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,10 @@ protected function registerTranslations(): void
123123
return;
124124
}
125125

126-
$path = implode(DIRECTORY_SEPARATOR, [
127-
$this->app['config']->get('modules.paths.modules'),
128-
'*',
129-
'lang',
130-
]);
131-
132-
collect(glob($path, GLOB_ONLYDIR))
133-
->each(function (string $path) use ($translator) {
134-
preg_match('/\/([^\/]+)\/lang/', $path, $matches);
135-
$translator->addNamespace(strtolower($matches[1]), $path);
126+
collect(\Nwidart\Modules\Facades\Module::allEnabled())
127+
->each(function (\Nwidart\Modules\Laravel\Module $module) use ($translator) {
128+
$path = $module->getExtraPath($this->app['config']->get('modules.paths.generator.lang.path'));
129+
$translator->addNamespace($module->getLowerName(), $path);
136130
$translator->addJsonPath($path);
137131
});
138132
});

0 commit comments

Comments
 (0)