@@ -8,50 +8,50 @@ function vsCodeGetTranslationsFromFile($file, $path, $namespace)
88 $ key = "{$ namespace }:: {$ key }" ;
99 }
1010
11- $ lang = collect (explode (DIRECTORY_SEPARATOR , str_replace ($ path , "" , $ file )))
11+ $ lang = collect (explode (DIRECTORY_SEPARATOR , str_replace ($ path , '' , $ file )))
1212 ->filter ()
1313 ->first ();
1414
15- $ fileLines = \ Illuminate \Support \Facades \File::lines ($ file );
15+ $ fileLines = Illuminate \Support \Facades \File::lines ($ file );
1616 $ lines = [];
1717 $ inComment = false ;
1818
1919 foreach ($ fileLines as $ index => $ line ) {
2020 $ trimmed = trim ($ line );
2121
22- if (substr ($ trimmed , 0 , 2 ) === " /* " ) {
22+ if (substr ($ trimmed , 0 , 2 ) === ' /* ' ) {
2323 $ inComment = true ;
2424 continue ;
2525 }
2626
2727 if ($ inComment ) {
28- if (substr ($ trimmed , -2 ) !== " */ " ) {
28+ if (substr ($ trimmed , -2 ) !== ' */ ' ) {
2929 continue ;
3030 }
3131
3232 $ inComment = false ;
3333 }
3434
35- if (substr ($ trimmed , 0 , 2 ) === " // " ) {
35+ if (substr ($ trimmed , 0 , 2 ) === ' // ' ) {
3636 continue ;
3737 }
3838
3939 $ lines [] = [$ index + 1 , $ trimmed ];
4040 }
4141
4242 return [
43- " k " => $ key ,
44- " la " => $ lang ,
45- " vs " => collect (\ Illuminate \Support \Arr::dot ((\ Illuminate \Support \Arr::wrap (__ ($ key , [], $ lang )))))
43+ ' k ' => $ key ,
44+ ' la ' => $ lang ,
45+ ' vs ' => collect (Illuminate \Support \Arr::dot ((Illuminate \Support \Arr::wrap (__ ($ key , [], $ lang )))))
4646 ->map (
47- fn ($ value , $ key ) => vsCodeTranslationValue (
47+ fn ($ value , $ key ) => vsCodeTranslationValue (
4848 $ key ,
4949 $ value ,
50- str_replace (base_path (DIRECTORY_SEPARATOR ), "" , $ file ),
50+ str_replace (base_path (DIRECTORY_SEPARATOR ), '' , $ file ),
5151 $ lines
5252 )
5353 )
54- ->filter ()
54+ ->filter (),
5555 ];
5656}
5757
@@ -62,7 +62,7 @@ function vsCodeTranslationValue($key, $value, $file, $lines): ?array
6262 }
6363
6464 $ lineNumber = 1 ;
65- $ keys = explode (" . " , $ key );
65+ $ keys = explode (' . ' , $ key );
6666 $ index = 0 ;
6767 $ currentKey = array_shift ($ keys );
6868
@@ -81,12 +81,12 @@ function vsCodeTranslationValue($key, $value, $file, $lines): ?array
8181 }
8282
8383 return [
84- " v " => $ value ,
85- " p " => $ file ,
86- " li " => $ lineNumber ,
87- " pa " => preg_match_all ("/\:([A-Za-z0-9_]+)/ " , $ value , $ matches )
84+ ' v ' => $ value ,
85+ ' p ' => $ file ,
86+ ' li ' => $ lineNumber ,
87+ ' pa ' => preg_match_all ("/\:([A-Za-z0-9_]+)/ " , $ value , $ matches )
8888 ? $ matches [1 ]
89- : []
89+ : [],
9090 ];
9191}
9292
@@ -98,44 +98,44 @@ function vscodeCollectTranslations(string $path, ?string $namespace = null)
9898 return collect ();
9999 }
100100
101- return collect (\ Illuminate \Support \Facades \File::allFiles ($ realPath ))->map (
102- fn ($ file ) => vsCodeGetTranslationsFromFile ($ file , $ path , $ namespace )
101+ return collect (Illuminate \Support \Facades \File::allFiles ($ realPath ))->map (
102+ fn ($ file ) => vsCodeGetTranslationsFromFile ($ file , $ path , $ namespace )
103103 );
104104}
105105
106- $ loader = app (" translator " )->getLoader ();
106+ $ loader = app (' translator ' )->getLoader ();
107107$ namespaces = $ loader ->namespaces ();
108108
109109$ reflection = new ReflectionClass ($ loader );
110- $ property = $ reflection ->hasProperty (" paths " )
111- ? $ reflection ->getProperty (" paths " )
112- : $ reflection ->getProperty (" path " );
110+ $ property = $ reflection ->hasProperty (' paths ' )
111+ ? $ reflection ->getProperty (' paths ' )
112+ : $ reflection ->getProperty (' path ' );
113113$ property ->setAccessible (true );
114114
115- $ paths = \ Illuminate \Support \Arr::wrap ($ property ->getValue ($ loader ));
115+ $ paths = Illuminate \Support \Arr::wrap ($ property ->getValue ($ loader ));
116116
117117$ default = collect ($ paths )->flatMap (
118- fn ($ path ) => vscodeCollectTranslations ($ path )
118+ fn ($ path ) => vscodeCollectTranslations ($ path )
119119);
120120
121121$ namespaced = collect ($ namespaces )->flatMap (
122- fn ($ path , $ namespace ) => vscodeCollectTranslations ($ path , $ namespace )
122+ fn ($ path , $ namespace ) => vscodeCollectTranslations ($ path , $ namespace )
123123);
124124
125125$ final = [];
126126
127127foreach ($ default ->merge ($ namespaced ) as $ value ) {
128- foreach ($ value [" vs " ] as $ key => $ v ) {
129- $ dotKey = "{$ value [" k " ]}. {$ key }" ;
128+ foreach ($ value [' vs ' ] as $ key => $ v ) {
129+ $ dotKey = "{$ value [' k ' ]}. {$ key }" ;
130130
131131 if (!isset ($ final [$ dotKey ])) {
132132 $ final [$ dotKey ] = [];
133133 }
134134
135- $ final [$ dotKey ][$ value [" la " ]] = $ v ;
135+ $ final [$ dotKey ][$ value [' la ' ]] = $ v ;
136136
137- if ($ value [" la " ] === \ Illuminate \Support \Facades \App::currentLocale ()) {
138- $ final [$ dotKey ][" default " ] = $ v ;
137+ if ($ value [' la ' ] === Illuminate \Support \Facades \App::currentLocale ()) {
138+ $ final [$ dotKey ][' default ' ] = $ v ;
139139 }
140140 }
141141}
0 commit comments