From 9989fd2b8b52c1976336b2239d41061ff355d125 Mon Sep 17 00:00:00 2001 From: Amir Rami Date: Mon, 16 Jan 2023 12:58:19 +0100 Subject: [PATCH] [Fix] `lang_path` for Laravel 9 (#49) --- composer.json | 1 - src/helpers.php | 4 +++- tests/LocalizatorTest.php | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 15916c3..cbac82f 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,6 @@ } }, "scripts": { - "psalm": "vendor/bin/psalm", "test": "vendor/bin/phpunit --colors=always", "test-coverage": "vendor/bin/phpunit --coverage-html coverage", "act": "act -P ubuntu-latest=shivammathur/node:latest -j" diff --git a/src/helpers.php b/src/helpers.php index 28221d7..c37c011 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -7,6 +7,8 @@ */ function lang_path($path = '') { - return resource_path('lang'.($path !== '' ? DIRECTORY_SEPARATOR.$path : '')); + return version_compare(app()->version(), '9.0', '>=') + ? app()->langPath($path) + : resource_path('lang'.($path !== '' ? DIRECTORY_SEPARATOR.$path : '')); } } diff --git a/tests/LocalizatorTest.php b/tests/LocalizatorTest.php index e59c32f..0c4ae03 100644 --- a/tests/LocalizatorTest.php +++ b/tests/LocalizatorTest.php @@ -344,7 +344,6 @@ public function testDirectoriesAreBeingExcluded(): void $this->createTestView("{{ __('Baz') }}", 'sub2/test'); config([ - 'localizator.sort' => false, 'localizator.search.exclude' => 'sub1', ]); @@ -356,8 +355,8 @@ public function testDirectoriesAreBeingExcluded(): void // Do their contents match the expected results? $contents = $this->getJsonLangContents('en'); self::assertSame([ - 'Foo' => 'Foo', 'Baz' => 'Baz', + 'Foo' => 'Foo', ], $contents); // Cleanup.