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.
Merge pull request #4 from fidum/dont-append-namespace-to-json-keys
Handle namespaced json files
- Loading branch information
Showing
13 changed files
with
150 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Fidum\LaravelTranslationLinter\Contracts\Factories; | ||
|
||
use Symfony\Component\Finder\SplFileInfo; | ||
|
||
interface LanguageNamespaceKeyFactory | ||
{ | ||
public function getNamespaceHintedKey(SplFileInfo $file, string $locale, string $namespaceHint, string $key): string; | ||
} |
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\Factories; | ||
|
||
use Fidum\LaravelTranslationLinter\Contracts\Factories\LanguageNamespaceKeyFactory as LanguageNamespaceKeyFactoryContract; | ||
use Fidum\LaravelTranslationLinter\Managers\LanguageFileReaderManager; | ||
use Symfony\Component\Finder\SplFileInfo; | ||
|
||
class LanguageNamespaceKeyFactory implements LanguageNamespaceKeyFactoryContract | ||
{ | ||
public function __construct(protected LanguageFileReaderManager $manager) {} | ||
|
||
public function getNamespaceHintedKey(SplFileInfo $file, string $locale, string $namespaceHint, string $key): string | ||
{ | ||
$extension = $file->getExtension(); | ||
|
||
if ($this->manager->isEnabled($extension)) { | ||
$reader = $this->manager->driver($extension); | ||
|
||
if ($reader instanceof LanguageNamespaceKeyFactoryContract) { | ||
return $reader->getNamespaceHintedKey($file, $locale, $namespaceHint, $key); | ||
} | ||
} | ||
|
||
return $key; | ||
} | ||
} |
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
5 changes: 4 additions & 1 deletion
5
tests/.pest/snapshots/Commands/UnusedCommandTest/it_errors_with_default_no_filters.snap
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
43 changes: 43 additions & 0 deletions
43
.../snapshots/Commands/UnusedCommandTest/it_errors_with_multiple_locales_and_no_filters.snap
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,43 @@ | ||
|
||
ERROR 36 unused translations found. | ||
|
||
+--------+-----------+------------------------------------+----------------------------------------------------+ | ||
| Locale | Namespace | Key | Value | | ||
+--------+-----------+------------------------------------+----------------------------------------------------+ | ||
| en | example | Unused Vendor PHP Class | I am unused in php class | | ||
| en | example | Unused Vendor Blade File | I am unused in blade | | ||
| en | example | Unused Vendor Vue Component | I am unused in vue component | | ||
| en | example | example.unused | I am unused in php class | | ||
| en | example | example.blade.choice.unused | I am unused in blade | | ||
| en | example | example.blade.lang.unused | I am unused in blade | | ||
| en | example | example.vue.unused | I am unused in vue component | | ||
| en | example | folder/example.unused | I am unused in php class | | ||
| en | example | folder/example.blade.choice.unused | I am unused in blade | | ||
| en | example | folder/example.blade.lang.unused | I am unused in blade | | ||
| en | example | folder/example.vue.unused | I am unused in vue component | | ||
| en | | Unused PHP Class | I am unused in php class | | ||
| en | | Unused Blade File | I am unused in blade | | ||
| en | | Unused Vue Component | I am unused in vue component | | ||
| en | | example.unused | I am unused in php class | | ||
| en | | example.blade.choice.unused | I am unused in blade | | ||
| en | | example.blade.lang.unused | I am unused in blade | | ||
| en | | example.vue.unused | I am unused in vue component | | ||
| en | | folder/example.unused | I am unused in php class | | ||
| en | | folder/example.blade.choice.unused | I am unused in blade | | ||
| en | | folder/example.blade.lang.unused | I am unused in blade | | ||
| en | | folder/example.vue.unused | I am unused in vue component | | ||
| de | example | Unused Vendor PHP Class | Ich werde in einer PHP-Klasse nicht verwendet | | ||
| de | example | Unused Vendor Blade File | Ich werde in Blade nicht verwendet | | ||
| de | example | Unused Vendor Vue Component | Ich werde in einem Vue-Komponenten nicht verwendet | | ||
| de | | Unused PHP Class | Ich werde in einer PHP-Klasse nicht verwendet | | ||
| de | | Unused Blade File | Ich werde in Blade nicht verwendet | | ||
| de | | Unused Vue Component | Ich werde in einem Vue-Komponenten nicht verwendet | | ||
| de | | example.unused | Ich werde in einer PHP-Klasse nicht verwendet | | ||
| de | | example.blade.choice.unused | Ich werde in Blade nicht verwendet | | ||
| de | | example.blade.lang.unused | Ich werde in Blade nicht verwendet | | ||
| de | | example.vue.unused | Ich werde in einem Vue-Komponenten nicht verwendet | | ||
| de | | folder/example.unused | Ich werde in einer PHP-Klasse nicht verwendet | | ||
| de | | folder/example.blade.choice.unused | Ich werde in Blade nicht verwendet | | ||
| de | | folder/example.blade.lang.unused | Ich werde in Blade nicht verwendet | | ||
| de | | folder/example.vue.unused | Ich werde in einem Vue-Komponenten nicht verwendet | | ||
+--------+-----------+------------------------------------+----------------------------------------------------+ |
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 |
---|---|---|
|
@@ -7,5 +7,6 @@ class ExampleJson | |
public function handle() | ||
{ | ||
__('Used PHP Class'); | ||
__('Used Vendor PHP Class'); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Used Vendor PHP Class": "Ich werde in einer PHP-Klasse verwendet", | ||
"Unused Vendor PHP Class": "Ich werde in einer PHP-Klasse nicht verwendet", | ||
"Used Vendor Blade File": "Ich werde in Blade verwendet", | ||
"Unused Vendor Blade File": "Ich werde in Blade nicht verwendet", | ||
"Used Vendor Vue Component": "Ich werde in einem Vue-Komponenten verwendet", | ||
"Unused Vendor Vue Component": "Ich werde in einem Vue-Komponenten nicht verwendet" | ||
} |
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,8 @@ | ||
{ | ||
"Used Vendor PHP Class": "I am used in php class", | ||
"Unused Vendor PHP Class": "I am unused in php class", | ||
"Used Vendor Blade File": "I am used in blade", | ||
"Unused Vendor Blade File": "I am unused in blade", | ||
"Used Vendor Vue Component": "I am used in vue component", | ||
"Unused Vendor Vue Component": "I am unused in vue component" | ||
} |