diff --git a/src/Mariuzzo/LaravelJsLocalization/LaravelJsLocalizationServiceProvider.php b/src/Mariuzzo/LaravelJsLocalization/LaravelJsLocalizationServiceProvider.php index 25fadf8..8b7f2ef 100644 --- a/src/Mariuzzo/LaravelJsLocalization/LaravelJsLocalizationServiceProvider.php +++ b/src/Mariuzzo/LaravelJsLocalization/LaravelJsLocalizationServiceProvider.php @@ -72,11 +72,15 @@ public function register() if ($laravelMajorVersion === 4) { $langs = $app['path.base'].'/app/lang'; - } elseif ($laravelMajorVersion >= 9) { + } + + // this is the path used by 5..8 laravel versions try to use it first. + $langs = $app['path.base'].'/resources/lang'; + + if (!is_dir($langs)) { $langs = $app['path.base'].'/lang'; - } elseif ($laravelMajorVersion >= 5) { - $langs = $app['path.base'].'/resources/lang'; } + $messages = $app['config']->get('localization-js.messages'); $generator = new Generators\LangJsGenerator($files, $langs, $messages); diff --git a/tests/specs/LangJsCommandTest.php b/tests/specs/LangJsCommandTest.php index 4465677..04e7c03 100644 --- a/tests/specs/LangJsCommandTest.php +++ b/tests/specs/LangJsCommandTest.php @@ -47,12 +47,9 @@ class LangJsCommandTest extends TestCase */ private $langPath; - /** - * LangJsCommandTest constructor. - */ - public function __construct() + protected function setUp(): void { - parent::__construct(); + parent::setUp(); $this->testPath = __DIR__ . '/..'; $this->rootPath = __DIR__ . '/../..'; @@ -240,7 +237,7 @@ public function testShouldIgnoreDefaultOutputPathFromConfigIfTargetArgumentExist $code = $this->runCommand($command, ['target' => $this->outputFilePath]); $this->assertRunsWithSuccess($code); $this->assertFileExists($this->outputFilePath); - $this->assertFileNotExists($customOutputFilePath); + $this->assertFileDoesNotExist($customOutputFilePath); $template = "$this->rootPath/src/Mariuzzo/LaravelJsLocalization/Generators/Templates/langjs_with_messages.js"; $this->assertFileExists($template);