generated from fidum/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
876 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ docs | |
phpunit.xml | ||
phpstan.neon | ||
testbench.yaml | ||
vendor | ||
/vendor | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,121 @@ | ||
<?php | ||
|
||
// config for Fidum/LaravelTranslationLinter | ||
return [ | ||
'application' => [ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Code Directories | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The following array lists the "directories" that will be scanned | ||
| for translations. The defaults below should cover most uses | ||
| but if you need to add more make sure they are absolute paths. | ||
| | ||
*/ | ||
'directories' => [ | ||
app_path(), | ||
resource_path(), | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Code Extensions | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The following array lists the file "extensions" that will be scanned for | ||
| translations. Make sure that all files where you use translations are | ||
| included here. | ||
| | ||
*/ | ||
'extensions' => [ | ||
'php', | ||
'js', | ||
'vue', | ||
], | ||
], | ||
|
||
'lang' => [ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Language Functions | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The following array lists the translation "functions" that will be used | ||
| to find translation usage throughout your code. This is used in the | ||
| regex pattern below to detect translations. | ||
| | ||
*/ | ||
'functions' => [ | ||
'__', | ||
'_t', | ||
'@lang', | ||
'@choice', | ||
'trans', | ||
'trans_choice', | ||
'Lang::choice', | ||
'Lang::get', | ||
'Lang::has', | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Language Function Regex Pattern | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The following contains the regex pattern used to find the functions | ||
| configured above. The '[FUNCTIONS]' part will be replaced with a | ||
| pipe delimited list of the functions defined above. | ||
| | ||
*/ | ||
'regex' => '/([FUNCTIONS])\([\t\r\n\s]*[\'"](.+)[\'"][\),\t\r\n\s]/U', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Language Locales | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The following array contains the language 'locales' to use. | ||
| | ||
*/ | ||
'locales' => [env('LOCALE_DEFAULT', 'en')], | ||
], | ||
|
||
'unused' => [ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Output Fields | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The following array lists the "fields" that are displayed by the command | ||
| when unused translations are found. Set any of these to `false` to hide | ||
| them from the output or change all to `false` to not show anything. | ||
| | ||
*/ | ||
'fields' => [ | ||
'lang' => true, | ||
'namespace' => true, | ||
'key' => true, | ||
'value' => true, | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Unused Language Filters | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The following array lists the "filters" that will be used to filter out | ||
| erroneously detected unused translations. For example, you may want to | ||
| ignore laravel or vendor translations. | ||
| | ||
| All filters must implement the filter interface or they will be skipped: | ||
| \Fidum\LaravelTranslationLinter\Contracts\Filter | ||
| | ||
| We have included some filters with this package which may be of use. | ||
| | ||
*/ | ||
'filters' => [ | ||
\Fidum\LaravelTranslationLinter\Filters\DefaultLanguageFilesFilter::class, | ||
\Fidum\LaravelTranslationLinter\Filters\IgnoreNamespacedKeysFilter::class, | ||
], | ||
], | ||
]; |
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
database/migrations/create_translation_linter_table.php.stub
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Fidum\LaravelTranslationLinter\Collections; | ||
|
||
use Fidum\LaravelTranslationLinter\Contracts\Collections\UnusedFieldCollection as UnusedFieldCollectionContract; | ||
use Illuminate\Support\Collection; | ||
use Illuminate\Support\Str; | ||
|
||
class UnusedFieldCollection extends Collection implements UnusedFieldCollectionContract | ||
{ | ||
public function enabled(): static | ||
{ | ||
return $this->filter()->keys(); | ||
Check failure on line 13 in src/Collections/UnusedFieldCollection.php GitHub Actions / phpstan
|
||
} | ||
|
||
public function headers(): array | ||
{ | ||
return $this->enabled() | ||
->map(fn ($v) => Str::headline($v)) | ||
->toArray(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Fidum\LaravelTranslationLinter\Collections; | ||
|
||
use Fidum\LaravelTranslationLinter\Contracts\Collections\UnusedFilterCollection as UnusedFilterCollectionContract; | ||
use Fidum\LaravelTranslationLinter\Contracts\Filters\Filter; | ||
use http\Exception\InvalidArgumentException; | ||
use Illuminate\Support\Collection; | ||
|
||
class UnusedFilterCollection extends Collection implements UnusedFilterCollectionContract | ||
{ | ||
public function shouldReport(string $lang, string $namespace, string $key, ?string $value): bool | ||
{ | ||
return $this->every(function (string $filterClass) use ($lang, $namespace, $key, $value) { | ||
$interface = Filter::class; | ||
|
||
if (is_subclass_of($filterClass, $interface)) { | ||
/** @var Filter $filter */ | ||
$filter = app($filterClass); | ||
|
||
return $filter->shouldReport($lang, $namespace, $key, $value); | ||
} | ||
|
||
throw new InvalidArgumentException("Filter [$filterClass] needs to implement [$interface]."); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Fidum\LaravelTranslationLinter\Collections; | ||
|
||
use Fidum\LaravelTranslationLinter\Contracts\Collections\UnusedFieldCollection as UnusedFieldCollectionContract; | ||
use Fidum\LaravelTranslationLinter\Contracts\Collections\UnusedResultCollection as UnusedResultCollectionContract; | ||
use Illuminate\Support\Arr; | ||
use Illuminate\Support\Collection; | ||
|
||
class UnusedResultCollection extends Collection implements UnusedResultCollectionContract | ||
{ | ||
public function addUnusedLanguageKey(string $lang, string $namespace, string $key, ?string $value): UnusedResultCollectionContract | ||
{ | ||
return $this->push([ | ||
'lang' => $lang, | ||
'namespace' => $namespace, | ||
'key' => $key, | ||
'value' => $value, | ||
]); | ||
} | ||
|
||
public function toCommandTableOutputArray(UnusedFieldCollectionContract $fields): array | ||
{ | ||
return Arr::only($this->items, $fields->enabled()->toArray()); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.