Skip to content

Commit

Permalink
handle malformed json
Browse files Browse the repository at this point in the history
  • Loading branch information
lsmith77 committed Sep 30, 2019
1 parent 6b17dfc commit ddcd061
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/GettextPOGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ private function addStringsFromJsonFiles($translations) {

// Load each JSON file to get source strings
foreach ($this->JsonFiles() as $jsonFile) {
$jsonTranslations = json_decode(file_get_contents($jsonFile), true);
$jsonTranslations = json_decode(file_get_contents($jsonFile), true);
if (!is_array($jsonTranslations)) {
throw new \Exception("The file '$jsonFile' is not valid JSON.'");
}

foreach ($jsonTranslations as $key => $value) {
$sourceStrings[] = $key;
Expand Down

0 comments on commit ddcd061

Please sign in to comment.