HTML handling v2

This commit is contained in:
2026-05-21 19:58:16 +00:00
parent 36f2b26ac7
commit 393779ab2f
3 changed files with 10 additions and 12 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
"type": "project",
"require": {
"php": ">=8.1",
"deeplcom/deepl-php": "^1.12",
"deeplcom/deepl-php": "^1.18",
"longman/telegram-bot": "*",
"lucadevelop/telegram-entities-decoder": "^1.3"
},
Generated
+7 -7
View File
@@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "ddef5561d74db6ff0a26bdf886e71bd0",
"content-hash": "85f6371654752b457d71015fa200e9a6",
"packages": [
{
"name": "deeplcom/deepl-php",
"version": "v1.12.0",
"version": "v1.18.0",
"source": {
"type": "git",
"url": "https://github.com/DeepLcom/deepl-php.git",
"reference": "b9a7e0385d27a99b7756ebf95e953785b90e8161"
"reference": "ca53d6e6907a71c47729ab160f0bbcbc059bed02"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/DeepLcom/deepl-php/zipball/b9a7e0385d27a99b7756ebf95e953785b90e8161",
"reference": "b9a7e0385d27a99b7756ebf95e953785b90e8161",
"url": "https://api.github.com/repos/DeepLcom/deepl-php/zipball/ca53d6e6907a71c47729ab160f0bbcbc059bed02",
"reference": "ca53d6e6907a71c47729ab160f0bbcbc059bed02",
"shasum": ""
},
"require": {
@@ -65,9 +65,9 @@
],
"support": {
"issues": "https://github.com/DeepLcom/deepl-php/issues",
"source": "https://github.com/DeepLcom/deepl-php/tree/v1.12.0"
"source": "https://github.com/DeepLcom/deepl-php/tree/v1.18.0"
},
"time": "2025-04-25T20:00:25+00:00"
"time": "2026-04-09T17:49:42+00:00"
},
{
"name": "guzzlehttp/guzzle",
+2 -4
View File
@@ -76,6 +76,7 @@ class GenericmessageCommand extends SystemCommand
];
if ($htmlMode) {
$deeplOptions[TranslateTextOptions::TAG_HANDLING] = 'html';
$deeplOptions[TranslateTextOptions::TAG_HANDLING_VERSION] = 'v2';
}
if (isset($deepl_glossary_id)) {
$deeplOptions[TranslateTextOptions::GLOSSARY] = $deepl_glossary_id;
@@ -85,15 +86,12 @@ class GenericmessageCommand extends SystemCommand
try {
if ($htmlMode) {
$text = (new EntityDecoder('HTML'))->decode(json_decode($message->toJson()));
// $text = str_replace("\n", '<br />', $text);
}
$translated = $this->translator->translateText($text, $sourceLang, $targetLang, $deeplOptions);
$translated = $translated->text;
} catch (\Exception $e) {
return $this->replyToChat(get_class($e) . ': ' . $e->getMessage()); // ?? var_export($e, true)
return $this->replyToChat(get_class($e) . ': ' . $e->getMessage());
}
$translated = str_replace('&lt;BR /&gt;', "\n", $translated);
// $translated = str_replace('<br />', "\n", $translated);
$forwardedFrom = $message->getForwardFrom();
if ($forwardedFrom) {