Browse Source

throw exception if cannot find translation file

tags/0.9.0
itismadness 4 years ago
parent
commit
da72835bc3
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      src/Parser/EAC/Translator.php

+ 5
- 1
src/Parser/EAC/Translator.php View File

@@ -18,9 +18,13 @@ class Translator
} }
$lang_directory = __DIR__ . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR; $lang_directory = __DIR__ . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR;
$english = json_decode(file_get_contents($lang_directory . 'en.json'), true); $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); $translation = json_decode(file_get_contents($lang_directory . $language_code . '.json'), true);
if ($translation === null) { 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) { foreach ($translation as $key => $value) {


Loading…
Cancel
Save