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

Use DIRECTORY_SEPARATOR instead of hardcoded chars #83

Merged
merged 2 commits into from
May 23, 2019
Merged
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
11 changes: 7 additions & 4 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ private function allocateLocaleArray($path, $multiLocales = false)
if ($fileinfo->isDir()) {
// Recursivley iterate through subdirs, until everything is allocated.

$data[$fileinfo->getFilename()] = $this->allocateLocaleArray($path . '/' . $fileinfo->getFilename());
$data[$fileinfo->getFilename()] = $this->allocateLocaleArray($path . DIRECTORY_SEPARATOR . $fileinfo->getFilename());
} else {
$noExt = $this->removeExtension($fileinfo->getFilename());
$fileName = $path . '/' . $fileinfo->getFilename();
$fileName = $path . DIRECTORY_SEPARATOR . $fileinfo->getFilename();

// Ignore non *.php files (ex.: .gitignore, vim swap files etc.)
if (pathinfo($fileName, PATHINFO_EXTENSION) !== 'php') {
Expand All @@ -234,10 +234,13 @@ private function allocateLocaleArray($path, $multiLocales = false)
continue;
}
if ($lastLocale !== false) {
$root = realpath(base_path() . $this->config['langPath'] . '/' . $lastLocale);
$root = realpath(base_path() . $this->config['langPath'] . DIRECTORY_SEPARATOR . $lastLocale);
$filePath = $this->removeExtension(str_replace('\\', '_', ltrim(str_replace($root, '', realpath($fileName)), '\\')));
if($filePath[0] === DIRECTORY_SEPARATOR) {
$filePath = substr($filePath, 1);
}
if ($multiLocales) {
$this->filesToCreate[$lastLocale][$lastLocale][substr($filePath, 1)] = $this->adjustArray($tmp);
$this->filesToCreate[$lastLocale][$lastLocale][$filePath] = $this->adjustArray($tmp);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not sure about this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer need to remove the leading '/' since it should be already removed at this point.

} else {
$this->filesToCreate[$filePath][$lastLocale] = $this->adjustArray($tmp);
}
Expand Down