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
9 changed files
with
69 additions
and
27 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
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 LanguageKeyFactory | ||
{ | ||
public function getLanguageKey(SplFileInfo $file, string $locale, 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
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\LanguageKeyFactory as LanguageKeyFactoryContract; | ||
use Fidum\LaravelTranslationLinter\Managers\LanguageFileReaderManager; | ||
use Symfony\Component\Finder\SplFileInfo; | ||
|
||
class LanguageKeyFactory implements LanguageKeyFactoryContract | ||
{ | ||
public function __construct(protected LanguageFileReaderManager $manager) {} | ||
|
||
public function getLanguageKey(SplFileInfo $file, string $locale, string $key): string | ||
{ | ||
$extension = $file->getExtension(); | ||
|
||
if ($this->manager->isEnabled($extension)) { | ||
$reader = $this->manager->driver($extension); | ||
|
||
if ($reader instanceof LanguageKeyFactoryContract) { | ||
return $reader->getLanguageKey($file, $locale, $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
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