Skip to content
This repository was archived by the owner on Jul 16, 2020. It is now read-only.

Commit fc4e344

Browse files
committed
Revert "Make generateMultiple and allocateLocaleArray deterministic (#105)"
This reverts commit 0e29f04.
1 parent 0e29f04 commit fc4e344

File tree

1 file changed

+19
-34
lines changed

1 file changed

+19
-34
lines changed

src/Generator.php

+19-34
Original file line numberDiff line numberDiff line change
@@ -129,39 +129,31 @@ public function generateMultiple($path, $format = 'es6', $multiLocales = false)
129129
$createdFiles = '';
130130
$dir = new DirectoryIterator($path);
131131
$jsBody = '';
132-
$files = [];
133-
134132
foreach ($dir as $fileinfo) {
135133
if (!$fileinfo->isDot()
136134
&& !in_array($fileinfo->getFilename(), array_merge(['vendor'], $this->config['excludes']))
137135
&& $fileinfo !== ''
138136
) {
139-
$files[] = $fileinfo->getRealPath();
140-
}
141-
}
142-
asort($files);
143-
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-
}
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+
}
160151

161-
if (isset($locales[$noExt])) {
162-
$locales[$noExt] = array_merge($local, $locales[$noExt]);
163-
} else {
164-
$locales[$noExt] = $local;
152+
if (isset($locales[$noExt])) {
153+
$locales[$noExt] = array_merge($local, $locales[$noExt]);
154+
} else {
155+
$locales[$noExt] = $local;
156+
}
165157
}
166158
}
167159
}
@@ -217,19 +209,12 @@ private function allocateLocaleArray($path, $multiLocales = false)
217209
$data = [];
218210
$dir = new DirectoryIterator($path);
219211
$lastLocale = last($this->availableLocales);
220-
$files = [];
221212
foreach ($dir as $fileinfo) {
222213
// Do not mess with dotfiles at all.
223214
if ($fileinfo->isDot()) {
224215
continue;
225216
}
226217

227-
$files[] = $fileinfo->getRealPath();
228-
}
229-
asort($files);
230-
231-
foreach ($files as $fileName) {
232-
$fileinfo = new \SplFileInfo($fileName);
233218
if ($fileinfo->isDir()) {
234219
// Recursivley iterate through subdirs, until everything is allocated.
235220

0 commit comments

Comments
 (0)