Skip to content

Commit e5928b4

Browse files
committed
fix command
1 parent e6d4d51 commit e5928b4

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Easily manage all your Laravel translation strings:
2424
You can install the package via Composer:
2525

2626
```bash
27-
composer require-dev elegantly/laravel-translator --dev
27+
composer require elegantly/laravel-translator --dev
2828
```
2929

3030
If you’re not using this package in production, add the following lines to your `.gitignore` file:

src/Commands/ShowMissingTranslationsCommand.php

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Symfony\Component\Console\Helper\TableSeparator;
99

1010
use function Laravel\Prompts\select;
11+
use function Laravel\Prompts\table;
1112

1213
class ShowMissingTranslationsCommand extends Command implements PromptsForMissingInput
1314
{
@@ -19,21 +20,31 @@ public function handle(): int
1920
{
2021
$reference = $this->argument('locale');
2122

22-
$rows = collect(Translator::getAllMissingTranslations($reference))
23-
->flatMap(
24-
fn ($namespaces, string $locale) => $namespaces
25-
->flatMap(function (array $keys, string $namespace) use ($locale, $namespaces) {
26-
$values = array_map(fn (string $key) => [$locale, "{$namespace}.$key"], $keys);
23+
$rows = [];
2724

28-
if ($namespaces->keys()->last() !== $namespace) {
29-
$values[] = [new TableSeparator, new TableSeparator];
30-
}
25+
$missing = Translator::getAllMissingTranslations($reference);
3126

32-
return $values;
33-
})
34-
)->toArray();
27+
foreach ($missing as $locale => $namespaces) {
3528

36-
$this->table(
29+
foreach ($namespaces as $namespace => $translations) {
30+
31+
foreach ($translations as $translation) {
32+
$rows[] = [$locale, "{$namespace}.{$translation}"];
33+
}
34+
35+
if ($namespaces->keys()->last() !== $namespace) {
36+
$rows[] = [new TableSeparator, new TableSeparator];
37+
}
38+
39+
}
40+
41+
if ($missing->keys()->last() !== $locale) {
42+
$rows[] = [new TableSeparator, new TableSeparator];
43+
}
44+
45+
}
46+
47+
table(
3748
headers: ['Locale', 'Missing key'],
3849
rows: $rows
3950
);

0 commit comments

Comments
 (0)