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

Commit

Permalink
Revert "Make generateMultiple and allocateLocaleArray deterministic (#…
Browse files Browse the repository at this point in the history
…105)"

This reverts commit 0e29f04.
  • Loading branch information
martinlindhe committed Feb 13, 2020
1 parent 0e29f04 commit fc4e344
Showing 1 changed file with 19 additions and 34 deletions.
53 changes: 19 additions & 34 deletions src/Generator.php
Expand Up @@ -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;
}
}
}
}
Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit fc4e344

Please sign in to comment.