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

Attempt on fixing --multi-locales #125

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function generateMultiple($path, $format = 'es6', $multiLocales = false)
foreach ($this->filesToCreate as $fileName => $data) {
$fileToCreate = $jsPath . $fileName . '.js';
$createdFiles .= $fileToCreate . PHP_EOL;
$jsonLocales = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . PHP_EOL;
$jsonLocales = json_encode([$fileName => $locales[$fileName]], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . PHP_EOL;
if (json_last_error() !== JSON_ERROR_NONE) {
throw new Exception('Could not generate JSON, error code '.json_last_error());
}
Expand Down Expand Up @@ -208,7 +208,6 @@ private function allocateLocaleArray($path, $multiLocales = false)
{
$data = [];
$dir = new DirectoryIterator($path);
$lastLocale = last($this->availableLocales);
foreach ($dir as $fileinfo) {
// Do not mess with dotfiles at all.
if ($fileinfo->isDot()) {
Expand All @@ -222,6 +221,7 @@ private function allocateLocaleArray($path, $multiLocales = false)
} else {
$noExt = $this->removeExtension($fileinfo->getFilename());
$fileName = $path . DIRECTORY_SEPARATOR . $fileinfo->getFilename();
$lastLocale = basename(dirname($fileName));

// Ignore non *.php files (ex.: .gitignore, vim swap files etc.)
if (pathinfo($fileName, PATHINFO_EXTENSION) !== 'php') {
Expand Down