Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle malformed json
Browse files Browse the repository at this point in the history
lsmith77 committed Sep 30, 2019
1 parent 234241c commit f1290a6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/GettextPOGenerator.php
Original file line number Diff line number Diff line change
@@ -165,6 +165,9 @@ 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);
if (!is_array($jsonTranslations)) {
throw new \Exception("The file '$jsonFile' is not valid JSON.'");
}

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

0 comments on commit f1290a6

Please sign in to comment.