Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Nwidart\Modules;

use Illuminate\Cache\CacheManager;
use Illuminate\Container\Container;
use Illuminate\Contracts\Translation\Translator;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -38,21 +36,11 @@ abstract class Module
*/
protected array $moduleJson = [];

/**
* Cache Manager
*/
private CacheManager $cache;

/**
* Filesystem
*/
private Filesystem $files;

/**
* Translator
*/
private Translator $translator;

/**
* ActivatorInterface
*/
Expand All @@ -65,9 +53,7 @@ public function __construct(Container $app, string $name, string $path)
{
$this->name = $name;
$this->path = $path;
$this->cache = $app['cache'];
$this->files = $app['files'];
$this->translator = $app['translator'];
$this->activator = $app[ActivatorInterface::class];
$this->app = $app;
}
Expand Down Expand Up @@ -395,6 +381,9 @@ protected function isLoadFilesOnBoot(): bool
*/
private function loadTranslationsFrom(string $path, string $namespace): void
{
$this->translator->addNamespace($namespace, $path);
// Use afterResolving to ensure translations are registered when translator becomes available
$this->app->afterResolving('translator', function ($translator) use ($path, $namespace) {
$translator->addNamespace($namespace, $path);
});
}
}