Skip to content

Commit 559e3f9

Browse files
authored
Merge pull request #10 from belguinan/master
Add json translation files support
2 parents 14f95f7 + ad7fc52 commit 559e3f9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/LaravelVueTranslation.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,17 @@ private function setTranslations()
5353
$path = $file->getRelativePathName();
5454
$this->printFileCompiled($path);
5555
$delimiter = strpos($path, '/') !== false ? '/' : '\\';
56+
5657
$array = array_map(function ($key) use ($file) {
5758
return str_replace('.' . $file->getExtension(), '', $key);
5859
}, explode($delimiter, $path));
59-
$nestedArray = $this->addArrayLevels($array, [], require $file->getPathName());
60+
61+
$nestedArray = $this->addArrayLevels($array, [],
62+
$file->getExtension() === 'json'
63+
? json_decode(file_get_contents($file->getPathName()), true)
64+
: require $file->getPathName()
65+
);
66+
6067
$this->translations = array_merge_recursive($this->translations, $nestedArray);
6168
}
6269
}

0 commit comments

Comments
 (0)