1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace ProcyonWeb\TranslationGenerator; |
||
6 | |||
7 | use Illuminate\Console\Command; |
||
8 | |||
9 | class ShowUntranslatedCommand extends Command |
||
10 | { |
||
11 | protected $signature = 'translation:show-missing {lang=hu}'; |
||
12 | |||
13 | protected $description = 'Show untranslated strings'; |
||
14 | |||
15 | public function handle(): void |
||
16 | { |
||
17 | $lang = $this->argument('lang'); |
||
18 | |||
19 | if (!file_exists('resources/lang/' . $lang . '.json')) { |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
20 | $this->error($lang . '.json doesn\'t exist'); |
||
21 | return; |
||
22 | } |
||
23 | |||
24 | $jsonFile = file_get_contents('resources/lang/' . $lang . '.json'); |
||
25 | |||
26 | $count = collect(json_decode($jsonFile, true)) |
||
27 | ->filter( |
||
28 | function ($value, $key) { |
||
29 | return $key === $value; |
||
30 | } |
||
31 | )->each( |
||
32 | function ($value) { |
||
33 | $this->line($value); |
||
34 | } |
||
35 | )->count(); |
||
36 | |||
37 | $this->info('Untranslated lines: ' . $count); |
||
38 | } |
||
39 | } |