diff --git a/src/Generator.php b/src/Generator.php index 1d0bbbe..8055cb2 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -129,39 +129,31 @@ public function generateMultiple($path, $format = 'es6', $multiLocales = false) $createdFiles = ''; $dir = new DirectoryIterator($path); $jsBody = ''; - $files = []; - foreach ($dir as $fileinfo) { if (!$fileinfo->isDot() && !in_array($fileinfo->getFilename(), array_merge(['vendor'], $this->config['excludes'])) && $fileinfo !== '' ) { - $files[] = $fileinfo->getRealPath(); - } - } - asort($files); - - foreach ($files as $fileName) { - $fileinfo = new \SplFileInfo($fileName); - $noExt = $this->removeExtension($fileinfo->getFilename()); - if ($noExt !== '') { - if (class_exists('App')) { - App::setLocale($noExt); - } - if (!in_array($noExt, $this->availableLocales)) { - $this->availableLocales[] = $noExt; - } - if ($fileinfo->isDir()) { - $local = $this->allocateLocaleArray($fileinfo->getRealPath(), $multiLocales); - } else { - $local = $this->allocateLocaleJSON($fileinfo->getRealPath()); - if ($local === null) continue; - } + $noExt = $this->removeExtension($fileinfo->getFilename()); + if ($noExt !== '') { + if (class_exists('App')) { + App::setLocale($noExt); + } + if (!in_array($noExt, $this->availableLocales)) { + $this->availableLocales[] = $noExt; + } + if ($fileinfo->isDir()) { + $local = $this->allocateLocaleArray($fileinfo->getRealPath(), $multiLocales); + } else { + $local = $this->allocateLocaleJSON($fileinfo->getRealPath()); + if ($local === null) continue; + } - if (isset($locales[$noExt])) { - $locales[$noExt] = array_merge($local, $locales[$noExt]); - } else { - $locales[$noExt] = $local; + if (isset($locales[$noExt])) { + $locales[$noExt] = array_merge($local, $locales[$noExt]); + } else { + $locales[$noExt] = $local; + } } } } @@ -217,19 +209,12 @@ private function allocateLocaleArray($path, $multiLocales = false) $data = []; $dir = new DirectoryIterator($path); $lastLocale = last($this->availableLocales); - $files = []; foreach ($dir as $fileinfo) { // Do not mess with dotfiles at all. if ($fileinfo->isDot()) { continue; } - $files[] = $fileinfo->getRealPath(); - } - asort($files); - - foreach ($files as $fileName) { - $fileinfo = new \SplFileInfo($fileName); if ($fileinfo->isDir()) { // Recursivley iterate through subdirs, until everything is allocated.