File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,12 @@ private function syncKeysFromFiles($translationFiles)
7979 if (isset ($ allKeysInFiles [$ fileName ])) {
8080 $ missingKeys = array_diff ($ allKeysInFiles [$ fileName ], array_keys (array_dot ($ fileContent )));
8181
82+ foreach ($ missingKeys as $ i => $ missingKey ) {
83+ if (Arr::has ($ fileContent , $ missingKey )) {
84+ unset($ missingKeys [$ i ]);
85+ }
86+ }
87+
8288 $ this ->fillMissingKeys ($ fileName , $ missingKeys , $ languageKey );
8389 }
8490 }
Original file line number Diff line number Diff line change @@ -69,4 +69,23 @@ public function testCommandOutputForMissingSubKey()
6969 array_map ('rmdir ' , glob (__DIR__ .'/views_temp/user ' ));
7070 array_map ('unlink ' , glob (__DIR__ .'/views_temp/user.blade.php ' ));
7171 }
72+
73+ public function testItDoesntOverrideParentKey ()
74+ {
75+ array_map ('unlink ' , glob (__DIR__ .'/views_temp/user/index.blade.php ' ));
76+
77+ file_put_contents (__DIR__ .'/views_temp/user.blade.php ' , '{{ trans( \'user.name \') }} ' );
78+
79+ $ this ->createTempFiles ([
80+ 'en ' => ['user ' => "<?php \n return ['name' => ['middle' => 'middle']]; " ],
81+ ]);
82+
83+ $ this ->artisan ('langman:sync ' );
84+
85+ $ userENFile = (array ) include $ this ->app ['config ' ]['langman.path ' ].'/en/user.php ' ;
86+
87+ $ this ->assertEquals (['middle ' => 'middle ' ], $ userENFile ['name ' ]);
88+
89+ array_map ('unlink ' , glob (__DIR__ .'/views_temp/user/index.blade.php ' ));
90+ }
7291}
You can’t perform that action at this time.
0 commit comments