From da72835bc31d02f37bdc4c8ea0b377401e2e4ff5 Mon Sep 17 00:00:00 2001 From: itismadness Date: Wed, 15 Apr 2020 05:56:35 -0800 Subject: [PATCH] throw exception if cannot find translation file --- src/Parser/EAC/Translator.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Parser/EAC/Translator.php b/src/Parser/EAC/Translator.php index 39f3f55..e78d908 100644 --- a/src/Parser/EAC/Translator.php +++ b/src/Parser/EAC/Translator.php @@ -18,9 +18,13 @@ class Translator } $lang_directory = __DIR__ . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR; $english = json_decode(file_get_contents($lang_directory . 'en.json'), true); + + if (!file_exists($lang_directory . $language_code . '.json')) { + throw new InvalidFileException('Could not find translation file for ' . $language_code . '.'); + } $translation = json_decode(file_get_contents($lang_directory . $language_code . '.json'), true); if ($translation === null) { - throw new InvalidFileException('Could not parse translation file for ' . $language_code); + throw new InvalidFileException('Could not parse translation file for ' . $language_code . '.'); } foreach ($translation as $key => $value) {