Просмотр исходного кода

wrap getLanguage call with try/catch and fallback to en default

tags/0.9.4
itismadness 4 лет назад
Родитель
Сommit
afb9fc8a4f
1 измененных файлов: 17 добавлений и 11 удалений
  1. +17
    -11
      src/Logchecker.php

+ 17
- 11
src/Logchecker.php Просмотреть файл

@@ -3,6 +3,7 @@
namespace OrpheusNET\Logchecker;

use OrpheusNET\Logchecker\Check\Ripper;
use OrpheusNET\Logchecker\Exception\UnknownLanguageException;
use OrpheusNET\Logchecker\Exception\UnknownRipperException;
use OrpheusNET\Logchecker\Parser\EAC\Translator;
use Symfony\Component\Yaml\Yaml;
@@ -366,17 +367,22 @@ class Logchecker
{
if ($this->ripper === Ripper::EAC) {
$translator = new Translator();
$lang = $translator->getLanguage($this->log);
if ($lang['code'] !== 'en') {
$this->language = $lang['code'];
$this->account(
"Translated log from {$lang['name']} ({$lang['name_english']}) to English.",
false,
false,
false,
true
);
$this->log = $translator->translate($this->log, $lang['code']);
try {
$lang = $translator->getLanguage($this->log);
if ($lang['code'] !== 'en') {
$this->language = $lang['code'];
$this->account(
"Translated log from {$lang['name']} ({$lang['name_english']}) to English.",
false,
false,
false,
true
);
$this->log = $translator->translate($this->log, $lang['code']);
}
} catch (UnknownLanguageException $exc) {
$this->language = 'en';
$this->account('Could not determine language. Assuming English.', false, false, false, true);
}
}



Загрузка…
Отмена
Сохранить