88use Symfony \Component \Console \Helper \TableSeparator ;
99
1010use function Laravel \Prompts \select ;
11+ use function Laravel \Prompts \table ;
1112
1213class 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