File tree Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -71,23 +71,20 @@ private function translateLangFiles(array $content): array
7171 {
7272 $ google = $ this ->setUpGoogleTranslate ();
7373
74+ if (!empty ($ content )) {
75+ return $ this ->translateRecursive ($ content , $ google );
76+ }
77+ }
78+
79+ private function translateRecursive ($ content , $ google ) : array
80+ {
7481 $ trans_data = [];
7582
76- if (!empty ($ content )) {
77- foreach ($ content as $ first_key => $ first_value ) {
78- if (is_array ($ first_value )) {
79- foreach ($ first_value as $ second_key => $ second_value ) {
80- if (is_array ($ second_value )) {
81- foreach ($ second_value as $ key => $ value ) {
82- $ trans_data [$ first_key ][$ second_key ][$ key ] = $ google ->translate ($ value );
83- }
84- } else {
85- $ trans_data [$ first_key ][$ second_key ] = $ google ->translate ($ second_value );
86- }
87- }
88- } else {
89- $ trans_data [$ first_key ] = $ google ->translate ($ first_value );
90- }
83+ foreach ($ content as $ key => $ value ) {
84+ if (!is_array ($ value )) {
85+ $ trans_data [$ key ] = $ google ->translate ($ value );
86+ } else {
87+ $ trans_data [$ key ] = $ this ->translateRecursive ($ value , $ google );
9188 }
9289 }
9390
You can’t perform that action at this time.
0 commit comments