/
Processor.php
43 lines (33 loc) · 1.16 KB
/
Processor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace LaravelLang\Lang\Processors\Splitters;
use LaravelLang\Lang\Processors\Processor as BaseProcessor;
abstract class Processor extends BaseProcessor
{
protected array $files = [
'packages/cashier.json',
'packages/fortify.json',
'packages/jetstream.json',
'packages/nova.json',
'packages/spark-paddle.json',
'packages/spark-stripe.json',
];
protected function process(string $target_path, string $filename, string $locale = null): void
{
$main = $this->load($this->main($locale));
$target = $this->load($target_path);
$content = $this->merge($main, $target, $filename);
$this->sort($content);
$this->store($target_path, $content);
}
protected function merge(array $source, array $target, string $filename): array
{
$source = $this->filter($source, $target);
return array_merge($target, $source);
}
protected function main(?string $locale): string
{
return empty($locale) || $locale === 'en'
? $this->getSourcePath('en.json')
: $this->getTargetPath($locale . '/' . $locale . '.json');
}
}