Skip to content

Commit eed7726

Browse files
okaufmannrmariuzzo
authored andcommitted
Ensure json translation files are valid (#129)
1 parent 7666413 commit eed7726

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Mariuzzo/LaravelJsLocalization/Generators/LangJsGenerator.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Mariuzzo\LaravelJsLocalization\Generators;
44

5+
use InvalidArgumentException;
56
use Illuminate\Filesystem\Filesystem as File;
67
use Illuminate\Support\Str;
78
use JShrink\Minifier;
@@ -149,6 +150,10 @@ protected function getMessages()
149150
$key = $key.$this->stringsDomain;
150151
$fileContent = file_get_contents($fullPath);
151152
$messages[$key] = json_decode($fileContent, true);
153+
154+
if (json_last_error() !== JSON_ERROR_NONE) {
155+
throw new InvalidArgumentException('Error while decode ' . basename($fullPath) . ': ' . json_last_error_msg());
156+
}
152157
}
153158
}
154159

0 commit comments

Comments
 (0)