@@ -23,33 +23,35 @@ class TranslationHelperCommand extends Command
2323 */
2424 public function handle ()
2525 {
26- $ translationKeys = $ this ->findProjectTranslationsKeys ();
26+ $ translationKeys = $ this ->findProjectTranslationsKeys ();
2727 $ translationFiles = $ this ->getProjectTranslationFiles ();
2828
2929 foreach ($ translationFiles as $ file ) {
3030 $ translationData = $ this ->getAlreadyTranslatedKeys ($ file );
31- $ this ->line ("Language: " . str_replace ('.json ' , '' , basename ($ file )));
32- $ added = [];
31+ $ added = [];
32+
33+ $ this ->line ('Language: ' . str_replace ('.json ' , '' , basename ($ file )));
3334
3435 foreach ($ translationKeys as $ key ) {
3536 if (!isset ($ translationData [$ key ])) {
36- $ this ->warn (" - Added: {$ key }" );
3737 $ translationData [$ key ] = '' ;
38- $ added [] = $ key ;
38+ $ added [] = $ key ;
39+
40+ $ this ->warn (" - Added: {$ key }" );
3941 }
4042 }
4143
4244 if ($ added ) {
43- $ this ->line (" Updating translation file... " );
45+ $ this ->line (' Updating translation file... ' );
4446
4547 $ this ->writeNewTranslationFile ($ file , $ translationData );
4648
47- $ this ->info (" Translation file have been updated! " );
49+ $ this ->info (' Translation file have been updated! ' );
4850 } else {
49- $ this ->warn (" Nothing new found for this language. " );
51+ $ this ->warn (' Nothing new found for this language. ' );
5052 }
5153
52- $ this ->line ("" );
54+ $ this ->line ('' );
5355 }
5456 }
5557
@@ -58,11 +60,11 @@ public function handle()
5860 */
5961 private function findProjectTranslationsKeys ()
6062 {
61- $ allKeys = [];
63+ $ allKeys = [];
6264 $ viewsDirectories = config ('translation-helper.scan_directories ' );
63- $ fileExtensions = config ('translation-helper.file_extensions ' );
65+ $ fileExtensions = config ('translation-helper.file_extensions ' );
6466
65- foreach ($ viewsDirectories as $ directory ) {
67+ foreach ($ viewsDirectories as $ directory ) {
6668 foreach ($ fileExtensions as $ extension ) {
6769 $ this ->getTranslationKeysFromDir ($ allKeys , $ directory , $ extension );
6870 }
@@ -102,11 +104,11 @@ private function getTranslationKeysFromFunction(&$keys, $functionName, $content)
102104
103105 preg_match_all ("# {$ functionName }\(\'(.*?)\'\)# " , $ content , $ matches );
104106
105- if ( ! empty ($ matches )) {
107+ if (! empty ($ matches )) {
106108 foreach ($ matches [1 ] as $ match ) {
107109 $ match = str_replace ('" ' , "' " , str_replace ("\' " , "' " , $ match ));
108110
109- if ( ! empty ($ match )) {
111+ if (! empty ($ match )) {
110112 $ keys [$ match ] = $ match ;
111113 }
112114 }
@@ -118,7 +120,7 @@ private function getTranslationKeysFromFunction(&$keys, $functionName, $content)
118120 */
119121 private function getProjectTranslationFiles ()
120122 {
121- $ path = config ('translation-helper.output_directory ' );
123+ $ path = config ('translation-helper.output_directory ' );
122124 $ files = glob ("{$ path }/*.json " , GLOB_BRACE );
123125
124126 return $ files ;
@@ -143,7 +145,7 @@ private function getAlreadyTranslatedKeys($filePath)
143145 */
144146 private function writeNewTranslationFile ($ filePath , $ translations )
145147 {
146- file_put_contents ($ filePath , json_encode ($ translations , JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE ));
148+ file_put_contents ($ filePath , json_encode ($ translations , JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE ));
147149 }
148150
149151 /**
0 commit comments