Files
lang/app/main/Processors/Keys.php
T
2022-04-21 16:20:57 +03:00

43 lines
949 B
PHP

<?php
namespace LaravelLang\Development\Processors;
use DragonCode\Support\Facades\Filesystem\File;
class Keys extends Processor
{
protected string $target_path = 'locales';
public function __construct(
protected ?string $locale = null
) {
}
public function run(): void
{
foreach ($this->locales() as $locale) {
foreach ($this->files($locale) as $file) {
$target_path = $this->getTargetPath($locale . '/' . $file);
$filename = $this->isMainJson($file) ? 'en.json' : $file;
$this->process($target_path, $filename, $locale);
}
}
}
protected function files(string $locale): array
{
return File::names($this->getTargetPath($locale));
}
protected function locales(): array
{
if ($this->locale) {
return [$this->locale];
}
return parent::locales();
}
}