@@ -25,6 +25,9 @@ public function __construct($config = [])
25
25
if (!isset ($ config ['i18nLib ' ])) {
26
26
$ config ['i18nLib ' ] = self ::VUE_I18N ;
27
27
}
28
+ if (!isset ($ config ['excludes ' ])) {
29
+ $ config ['excludes ' ] = [];
30
+ }
28
31
$ this ->config = $ config ;
29
32
}
30
33
@@ -49,7 +52,9 @@ public function generateFromPath($path, $format = 'es6', $withVendor = false, $l
49
52
$ jsBody = '' ;
50
53
foreach ($ dir as $ fileinfo ) {
51
54
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
+ ) {
53
58
continue ;
54
59
}
55
60
@@ -62,21 +67,23 @@ public function generateFromPath($path, $format = 'es6', $withVendor = false, $l
62
67
$ fileinfo = new \SplFileInfo ($ fileName );
63
68
64
69
$ 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
+ }
68
74
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
+ }
75
81
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
+ }
80
87
}
81
88
}
82
89
@@ -120,29 +127,30 @@ public function generateMultiple($path, $format = 'es6')
120
127
$ jsBody = '' ;
121
128
foreach ($ dir as $ fileinfo ) {
122
129
if (!$ fileinfo ->isDot ()
123
- && !in_array ($ fileinfo ->getFilename (), ['vendor ' ])
130
+ && !in_array ($ fileinfo ->getFilename (), array_merge (['vendor ' ], $ this ->config ['excludes ' ]))
131
+ && $ fileinfo !== ''
124
132
) {
125
133
$ 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
+ }
138
147
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
+ }
143
153
}
144
-
145
-
146
154
}
147
155
}
148
156
foreach ($ this ->filesToCreate as $ fileName => $ data ) {
0 commit comments