Glossary v3
This commit is contained in:
@@ -22,7 +22,7 @@ class GenericmessageCommand extends SystemCommand
|
||||
|
||||
public function execute(): ServerResponse
|
||||
{
|
||||
global $deepl_api_key, $allowed_chat_ids;
|
||||
global $deepl_api_key, $deepl_glossary_id, $allowed_chat_ids;
|
||||
|
||||
$message = $this->getMessage();
|
||||
$chat_id = $message->getChat()->getId();
|
||||
@@ -51,14 +51,9 @@ class GenericmessageCommand extends SystemCommand
|
||||
TranslateTextOptions::TAG_HANDLING => 'html',
|
||||
TranslateTextOptions::SPLIT_SENTENCES => 'on',
|
||||
];
|
||||
try {
|
||||
$glosasaryConfig = json_decode(file_get_contents(__DIR__ . '/../../glossary.json'), true);
|
||||
$targetLangKey = explode('-', $targetLang)[0];
|
||||
if (isset($glosasaryConfig[$sourceLang][$targetLangKey])) {
|
||||
$deeplOptions[TranslateTextOptions::GLOSSARY] = $glosasaryConfig[$sourceLang][$targetLangKey];
|
||||
|
||||
}
|
||||
} catch(\Exception $e) {}
|
||||
if (isset($deepl_glossary_id)) {
|
||||
$deeplOptions[TranslateTextOptions::GLOSSARY] = $deepl_glossary_id;
|
||||
}
|
||||
|
||||
$this->translator = new Translator($deepl_api_key);
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user