@@ -25,6 +25,9 @@ public function __construct($config = [])
2525 if (!isset ($ config ['i18nLib ' ])) {
2626 $ config ['i18nLib ' ] = self ::VUE_I18N ;
2727 }
28+ if (!isset ($ config ['excludes ' ])) {
29+ $ config ['excludes ' ] = [];
30+ }
2831 $ this ->config = $ config ;
2932 }
3033
@@ -49,7 +52,9 @@ public function generateFromPath($path, $format = 'es6', $withVendor = false, $l
4952 $ jsBody = '' ;
5053 foreach ($ dir as $ fileinfo ) {
5154 if (!$ fileinfo ->isDot ()) {
52- if (!$ withVendor && in_array ($ fileinfo ->getFilename (), ['vendor ' ])) {
55+ if (!$ withVendor
56+ && in_array ($ fileinfo ->getFilename (), array_merge (['vendor ' ], $ this ->config ['excludes ' ]))
57+ ) {
5358 continue ;
5459 }
5560
@@ -62,21 +67,23 @@ public function generateFromPath($path, $format = 'es6', $withVendor = false, $l
6267 $ fileinfo = new \SplFileInfo ($ fileName );
6368
6469 $ noExt = $ this ->removeExtension ($ fileinfo ->getFilename ());
65- if (class_exists ('App ' )) {
66- App::setLocale ($ noExt );
67- }
70+ if ($ noExt !== '' ) {
71+ if (class_exists ('App ' )) {
72+ App::setLocale ($ noExt );
73+ }
6874
69- if ($ fileinfo ->isDir ()) {
70- $ local = $ this ->allocateLocaleArray ($ fileinfo ->getRealPath ());
71- } else {
72- $ local = $ this ->allocateLocaleJSON ($ fileinfo ->getRealPath ());
73- if ($ local === null ) continue ;
74- }
75+ if ($ fileinfo ->isDir ()) {
76+ $ local = $ this ->allocateLocaleArray ($ fileinfo ->getRealPath ());
77+ } else {
78+ $ local = $ this ->allocateLocaleJSON ($ fileinfo ->getRealPath ());
79+ if ($ local === null ) continue ;
80+ }
7581
76- if (isset ($ locales [$ noExt ])) {
77- $ locales [$ noExt ] = array_merge ($ local , $ locales [$ noExt ]);
78- } else {
79- $ locales [$ noExt ] = $ local ;
82+ if (isset ($ locales [$ noExt ])) {
83+ $ locales [$ noExt ] = array_merge ($ local , $ locales [$ noExt ]);
84+ } else {
85+ $ locales [$ noExt ] = $ local ;
86+ }
8087 }
8188 }
8289
@@ -120,29 +127,30 @@ public function generateMultiple($path, $format = 'es6')
120127 $ jsBody = '' ;
121128 foreach ($ dir as $ fileinfo ) {
122129 if (!$ fileinfo ->isDot ()
123- && !in_array ($ fileinfo ->getFilename (), ['vendor ' ])
130+ && !in_array ($ fileinfo ->getFilename (), array_merge (['vendor ' ], $ this ->config ['excludes ' ]))
131+ && $ fileinfo !== ''
124132 ) {
125133 $ noExt = $ this ->removeExtension ($ fileinfo ->getFilename ());
126- if (class_exists ('App ' )) {
127- App::setLocale ($ noExt );
128- }
129- if (!in_array ($ noExt , $ this ->availableLocales )) {
130- $ this ->availableLocales [] = $ noExt ;
131- }
132- if ($ fileinfo ->isDir ()) {
133- $ local = $ this ->allocateLocaleArray ($ fileinfo ->getRealPath ());
134- } else {
135- $ local = $ this ->allocateLocaleJSON ($ fileinfo ->getRealPath ());
136- if ($ local === null ) continue ;
137- }
134+ if ($ noExt !== '' ) {
135+ if (class_exists ('App ' )) {
136+ App::setLocale ($ noExt );
137+ }
138+ if (!in_array ($ noExt , $ this ->availableLocales )) {
139+ $ this ->availableLocales [] = $ noExt ;
140+ }
141+ if ($ fileinfo ->isDir ()) {
142+ $ local = $ this ->allocateLocaleArray ($ fileinfo ->getRealPath ());
143+ } else {
144+ $ local = $ this ->allocateLocaleJSON ($ fileinfo ->getRealPath ());
145+ if ($ local === null ) continue ;
146+ }
138147
139- if (isset ($ locales [$ noExt ])) {
140- $ locales [$ noExt ] = array_merge ($ local , $ locales [$ noExt ]);
141- } else {
142- $ locales [$ noExt ] = $ local ;
148+ if (isset ($ locales [$ noExt ])) {
149+ $ locales [$ noExt ] = array_merge ($ local , $ locales [$ noExt ]);
150+ } else {
151+ $ locales [$ noExt ] = $ local ;
152+ }
143153 }
144-
145-
146154 }
147155 }
148156 foreach ($ this ->filesToCreate as $ fileName => $ data ) {
0 commit comments