Skip to content

Commit

Permalink
feat: handle multiple paths
Browse files Browse the repository at this point in the history
  • Loading branch information
nerg4l committed Jan 19, 2024
1 parent 892411e commit 1c8e4e6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
11 changes: 7 additions & 4 deletions config/lost-in-translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@

/*
|--------------------------------------------------------------------------
| Lost in Translation path
| Lost in Translation paths
|--------------------------------------------------------------------------
|
| Here you may specify the path that should be used by the service.
| The path tells where the blade files are located.
| Here you may specify the paths that should be scanned by the service.
| The root directories of your blade and application files.
|
*/

'path' => resource_path('views'),
'paths' => [
app_path(),
resource_path('views'),
],

/*
|--------------------------------------------------------------------------
Expand Down
13 changes: 8 additions & 5 deletions src/Console/Commands/FindMissingTranslationStrings.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ public function handle(LostInTranslation $lit)
{
$locale = $this->argument('locale');

$files = File::allFiles(config('lost-in-translation.path'));

$files = Collection::make($files)->filter(function (\SplFileInfo $file) {
return Str::endsWith($file->getExtension(), 'php');
});
$files = Collection::make(config('lost-in-translation.paths'))
->map(function (string $path) {
return File::allFiles($path);
})
->flatten()
->unique()->filter(function (\SplFileInfo $file) {
return Str::endsWith($file->getExtension(), 'php');
});

$reported = [];
$keys = [];
Expand Down
7 changes: 5 additions & 2 deletions tests/LostInTranslationServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ public function testDefaultConfig()
{
$config = $this->app->make('config')->get('lost-in-translation');

$this->assertArrayHasKey('path', $config);
$this->assertIsString($config['path']);
$this->assertArrayHasKey('paths', $config);
$this->assertIsArray($config['paths']);
$this->assertCount(2, $config['paths']);
$this->assertIsString($config['paths'][0]);
$this->assertIsString($config['paths'][1]);

$this->assertArrayHasKey('locale', $config);
$this->assertEquals('en', $config['locale']);
Expand Down

0 comments on commit 1c8e4e6

Please sign in to comment.