Skip to content

fix langs path to support new laravel versions but old resources/lang dir #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
9 changes: 3 additions & 6 deletions tests/specs/LangJsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__ . '/../..';
Expand Down Expand Up @@ -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);
Expand Down