Skip to content

Commit

Permalink
Separate locales config foreach command
Browse files Browse the repository at this point in the history
  • Loading branch information
dmason30 committed Nov 23, 2023
1 parent 8b832f4 commit 90bcff6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
33 changes: 22 additions & 11 deletions config/translation-linter.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,6 @@
'Lang::has',
],

/*
|--------------------------------------------------------------------------
| Language Locales
|--------------------------------------------------------------------------
|
| The following array contains the "locales" to use when finding all of
| your registered language files.
|
*/
'locales' => [env('LOCALE_DEFAULT', 'en')],

/*
|--------------------------------------------------------------------------
| Language File Readers
Expand Down Expand Up @@ -130,6 +119,17 @@
|
*/
'filters' => [],

/*
|--------------------------------------------------------------------------
| Language Locales
|--------------------------------------------------------------------------
|
| The following array contains the "locales" to use when finding all of
| your registered language files.
|
*/
'locales' => [env('LOCALE_DEFAULT', 'en')],
],

'unused' => [
Expand Down Expand Up @@ -181,5 +181,16 @@
\Fidum\LaravelTranslationLinter\Filters\IgnoreNamespacedKeysFilter::class,
\Fidum\LaravelTranslationLinter\Filters\IgnoreVendorKeysFilter::class,
],

/*
|--------------------------------------------------------------------------
| Language Locales
|--------------------------------------------------------------------------
|
| The following array contains the "locales" to use when finding all of
| your registered language files.
|
*/
'locales' => [env('LOCALE_DEFAULT', 'en')],
],
];
4 changes: 2 additions & 2 deletions src/LaravelTranslationLinterServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function registeringPackage()

$this->app->when(MissingTranslationLinter::class)
->needs('$locales')
->giveConfig('translation-linter.lang.locales');
->giveConfig('translation-linter.missing.locales');

$this->app->bind(ResultObjectCollectionContract::class, ResultObjectCollection::class);

Expand Down Expand Up @@ -154,7 +154,7 @@ public function registeringPackage()

$this->app->when(UnusedTranslationLinter::class)
->needs('$locales')
->giveConfig('translation-linter.lang.locales');
->giveConfig('translation-linter.unused.locales');
}

public function provides()
Expand Down
6 changes: 3 additions & 3 deletions tests/Commands/MissingCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
});

it('errors with multiple locales', function () {
config()->set('translation-linter.lang.locales', ['en', 'de']);
config()->set('translation-linter.missing.locales', ['en', 'de']);
$firstFile = workbench_path('app/ExampleJson.php');

withoutMockingConsoleOutput();
Expand All @@ -64,7 +64,7 @@
});

it('generates baseline file then successfully ignores baseline keys', function () {
config()->set('translation-linter.lang.locales', ['en', 'de']);
config()->set('translation-linter.missing.locales', ['en', 'de']);

withoutMockingConsoleOutput();
expect(artisan('translation:missing --generate-baseline'))
Expand All @@ -84,7 +84,7 @@
});

it('outputs success message when no missing translations found', function () {
config()->set('translation-linter.lang.locales', []);
config()->set('translation-linter.missing.locales', []);
withoutMockingConsoleOutput();
expect(artisan('translation:missing'))
->toBe(0)
Expand Down
8 changes: 4 additions & 4 deletions tests/Commands/UnusedCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
});

it('errors with multiple locales', function () {
config()->set('translation-linter.lang.locales', ['en', 'de']);
config()->set('translation-linter.unused.locales', ['en', 'de']);
withoutMockingConsoleOutput();
expect(artisan('translation:unused'))
->toBe(1)
Expand All @@ -60,7 +60,7 @@
});

it('errors with multiple locales and no filters', function () {
config()->set('translation-linter.lang.locales', ['en', 'de']);
config()->set('translation-linter.unused.locales', ['en', 'de']);
config()->set('translation-linter.unused.filters', []);

withoutMockingConsoleOutput();
Expand All @@ -71,7 +71,7 @@
});

it('generates baseline file then successfully ignores baseline keys', function () {
config()->set('translation-linter.lang.locales', ['en', 'de']);
config()->set('translation-linter.unused.locales', ['en', 'de']);
config()->set('translation-linter.unused.filters', [IgnoreKeysFromUnusedBaselineFileFilter::class]);

withoutMockingConsoleOutput();
Expand All @@ -92,7 +92,7 @@
});

it('outputs success message when no unused translations found', function () {
config()->set('translation-linter.lang.locales', []);
config()->set('translation-linter.unused.locales', []);
withoutMockingConsoleOutput();
expect(artisan('translation:unused'))
->toBe(0)
Expand Down

0 comments on commit 90bcff6

Please sign in to comment.