@@ -129,31 +129,39 @@ public function generateMultiple($path, $format = 'es6', $multiLocales = false)
129
129
$ createdFiles = '' ;
130
130
$ dir = new DirectoryIterator ($ path );
131
131
$ jsBody = '' ;
132
+ $ files = [];
133
+
132
134
foreach ($ dir as $ fileinfo ) {
133
135
if (!$ fileinfo ->isDot ()
134
136
&& !in_array ($ fileinfo ->getFilename (), array_merge (['vendor ' ], $ this ->config ['excludes ' ]))
135
137
&& $ fileinfo !== ''
136
138
) {
137
- $ noExt = $ this ->removeExtension ($ fileinfo ->getFilename ());
138
- if ($ noExt !== '' ) {
139
- if (class_exists ('App ' )) {
140
- App::setLocale ($ noExt );
141
- }
142
- if (!in_array ($ noExt , $ this ->availableLocales )) {
143
- $ this ->availableLocales [] = $ noExt ;
144
- }
145
- if ($ fileinfo ->isDir ()) {
146
- $ local = $ this ->allocateLocaleArray ($ fileinfo ->getRealPath (), $ multiLocales );
147
- } else {
148
- $ local = $ this ->allocateLocaleJSON ($ fileinfo ->getRealPath ());
149
- if ($ local === null ) continue ;
150
- }
139
+ $ files [] = $ fileinfo ->getRealPath ();
140
+ }
141
+ }
142
+ asort ($ files );
151
143
152
- if (isset ($ locales [$ noExt ])) {
153
- $ locales [$ noExt ] = array_merge ($ local , $ locales [$ noExt ]);
154
- } else {
155
- $ locales [$ noExt ] = $ local ;
156
- }
144
+ foreach ($ files as $ fileName ) {
145
+ $ fileinfo = new \SplFileInfo ($ fileName );
146
+ $ noExt = $ this ->removeExtension ($ fileinfo ->getFilename ());
147
+ if ($ noExt !== '' ) {
148
+ if (class_exists ('App ' )) {
149
+ App::setLocale ($ noExt );
150
+ }
151
+ if (!in_array ($ noExt , $ this ->availableLocales )) {
152
+ $ this ->availableLocales [] = $ noExt ;
153
+ }
154
+ if ($ fileinfo ->isDir ()) {
155
+ $ local = $ this ->allocateLocaleArray ($ fileinfo ->getRealPath (), $ multiLocales );
156
+ } else {
157
+ $ local = $ this ->allocateLocaleJSON ($ fileinfo ->getRealPath ());
158
+ if ($ local === null ) continue ;
159
+ }
160
+
161
+ if (isset ($ locales [$ noExt ])) {
162
+ $ locales [$ noExt ] = array_merge ($ local , $ locales [$ noExt ]);
163
+ } else {
164
+ $ locales [$ noExt ] = $ local ;
157
165
}
158
166
}
159
167
}
@@ -209,12 +217,19 @@ private function allocateLocaleArray($path, $multiLocales = false)
209
217
$ data = [];
210
218
$ dir = new DirectoryIterator ($ path );
211
219
$ lastLocale = last ($ this ->availableLocales );
220
+ $ files = [];
212
221
foreach ($ dir as $ fileinfo ) {
213
222
// Do not mess with dotfiles at all.
214
223
if ($ fileinfo ->isDot ()) {
215
224
continue ;
216
225
}
217
226
227
+ $ files [] = $ fileinfo ->getRealPath ();
228
+ }
229
+ asort ($ files );
230
+
231
+ foreach ($ files as $ fileName ) {
232
+ $ fileinfo = new \SplFileInfo ($ fileName );
218
233
if ($ fileinfo ->isDir ()) {
219
234
// Recursivley iterate through subdirs, until everything is allocated.
220
235
0 commit comments