Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dmason30 committed Oct 30, 2023
1 parent d51d68a commit bf12909
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
9 changes: 4 additions & 5 deletions src/Commands/FakeTranslationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,20 @@ class FakeTranslationCommand extends Command
public $description = 'Generates pseudo language files from another locale to make it easy to see what still needs translating.';

public function handle(
LanguageFileFinder $finder,
Filesystem $filesystem,
LanguageFileFinder $languageFileFinder,
LanguageFilePrinter $printer,
LanguageFileReader $reader,
LanguageNamespaceFinder $namespaceFinder,
LanguageOutputFactory $factory,
Filesystem $filesystem,
ReplacerCollection $replacers,
): int {
$locale = $this->argument('locale');
$baseLocale = $this->option('baseLocale') ?: config('translation-faker.default');
$converter = $replacers->toConverterCollection($baseLocale);
$namespaces = $namespaceFinder->execute();

foreach ($namespaces as $path) {
$files = $finder->execute($path, $baseLocale);
foreach ($namespaceFinder->execute() as $path) {
$files = $languageFileFinder->execute($path, $baseLocale);

/** @var SplFileInfo $file */
foreach ($files as $file) {
Expand Down
4 changes: 2 additions & 2 deletions src/Contracts/Printers/LanguageFilePrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Fidum\LaravelTranslationFaker\Contracts\Printers;

use Illuminate\Support\Collection;
use Fidum\LaravelTranslationFaker\Contracts\Collections\TranslationCollection as TranslationCollectionContract;
use Symfony\Component\Finder\SplFileInfo;

interface LanguageFilePrinter
{
public function execute(SplFileInfo $file, Collection $items): string;
public function execute(SplFileInfo $file, TranslationCollectionContract $items): string;
}
1 change: 1 addition & 0 deletions src/LaravelTranslationFakerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function provides()
LanguageFileReaderManager::class,
LanguageNamespaceFinderContract::class,
ReplacerCollectionContract::class,
TranslationCollectionContract::class,
];
}
}
6 changes: 3 additions & 3 deletions src/Printers/JsonLanguageFilePrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace Fidum\LaravelTranslationFaker\Printers;

use Fidum\LaravelTranslationFaker\Contracts\Collections\TranslationCollection as TranslationCollectionContract;
use Fidum\LaravelTranslationFaker\Contracts\Printers\LanguageFilePrinter as LanguageFilePrinterContract;
use Illuminate\Support\Collection;
use Symfony\Component\Finder\SplFileInfo;

class JsonLanguageFilePrinter implements LanguageFilePrinterContract
{
protected const JSON_OPTIONS = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;

public function execute(SplFileInfo $file, Collection $items): string
public function execute(SplFileInfo $file, TranslationCollectionContract $items): string
{
return json_encode($items, static::JSON_OPTIONS);
return $items->toJson(static::JSON_OPTIONS);
}
}
4 changes: 2 additions & 2 deletions src/Printers/LanguageFilePrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Fidum\LaravelTranslationFaker\Printers;

use Fidum\LaravelTranslationFaker\Contracts\Collections\TranslationCollection as TranslationCollectionContract;
use Fidum\LaravelTranslationFaker\Contracts\Printers\LanguageFilePrinter as LanguageFilePrinterContract;
use Fidum\LaravelTranslationFaker\Managers\LanguageFilePrinterManager;
use Illuminate\Support\Collection;
use InvalidArgumentException;
use Symfony\Component\Finder\SplFileInfo;

Expand All @@ -14,7 +14,7 @@ class LanguageFilePrinter implements LanguageFilePrinterContract

public function __construct(protected LanguageFilePrinterManager $manager) {}

public function execute(SplFileInfo $file, Collection $items): string
public function execute(SplFileInfo $file, TranslationCollectionContract $items): string
{
$extension = $file->getExtension();
$translations = '';
Expand Down
4 changes: 2 additions & 2 deletions src/Printers/PhpLanguageFilePrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Fidum\LaravelTranslationFaker\Printers;

use Fidum\LaravelTranslationFaker\Contracts\Collections\TranslationCollection as TranslationCollectionContract;
use Fidum\LaravelTranslationFaker\Contracts\Printers\LanguageFilePrinter as LanguageFilePrinterContract;
use Illuminate\Support\Collection;
use Symfony\Component\Finder\SplFileInfo;

class PhpLanguageFilePrinter implements LanguageFilePrinterContract
{
public function execute(SplFileInfo $file, Collection $items): string
public function execute(SplFileInfo $file, TranslationCollectionContract $items): string
{
$body = $this->build($items->toArray(), 1);

Expand Down

0 comments on commit bf12909

Please sign in to comment.