Skip to content

Commit

Permalink
fix translations support
Browse files Browse the repository at this point in the history
  • Loading branch information
mozex committed Mar 3, 2024
1 parent c068b61 commit 9c9b852
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion config/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
AssetType::Translations->value => [
'active' => true,
'patterns' => [
'*/Resources/lang',
'*/Lang',
],
],
AssetType::Schedules->value => [
Expand Down
5 changes: 4 additions & 1 deletion src/ModulesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ protected function bootTranslations(): void

AssetType::Translations->scout()->collect()
->each(function (array $asset): void {
$this->loadTranslationsFrom($asset['path'], $asset['module']);
$this->loadTranslationsFrom(
path: $asset['path'],
namespace: $this->lowerDashedName($asset['module'])
);
$this->loadJsonTranslationsFrom($asset['path']);
});
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/TranslationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
expect($collection)
->each->toHaveKeys(['module', 'path', 'namespace'])
->and($collection->pluck('path'))
->toContain(realpath(Modules::modulesPath('First/Resources/lang')))
->toContain(realpath(Modules::modulesPath('Second/Resources/lang')));
->toContain(realpath(Modules::modulesPath('First/Lang')))
->toContain(realpath(Modules::modulesPath('Second/Lang')));

if ($cache) {
$discoverer->clear();
Expand All @@ -55,7 +55,7 @@

$discoverer->collect()
->each(function (array $asset) use ($loader) {
expect($loader->namespaces())->toHaveKey($asset['module'])->toContain($asset['path'])
expect($loader->namespaces())->toHaveKey(strtolower($asset['module']))->toContain($asset['path'])
->and($loader->jsonPaths())->toContain($asset['path']);
});

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 9c9b852

Please sign in to comment.