-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
After sending a request with the following text as content in TextMedia bodytext:
<p>Important species in blueberry include the Western flower thrips (<em>Frankliniella occidentalis</em>) and Chilli thrips (<em>Scirtothrips dorsalis</em>).</p>
the result received from the API is:
<p>Belangrijke soorten in blauwe bes zijn de californische trips<em>(Frankliniella occidentalis</em>) en chilipeper trips<em>(Scirtothrips dorsalis</em>).</p>
tags have been moved, and there is a space missing. I checked this directly with xdebug in the $response->translations->[0]->text response.
To Reproduce
- Create a content element
- Add the source text
- Request translation
- Result has some spaces removed before text in ()
Expected behavior
Text is translation with same formatting
Screenshots
If applicable, add screenshots to help explain your problem.
TYPO3 Setup
- TYPO3 Version - V10.4.37
- Server (Apache)
- Database type and version (MySQL)
- PHP version - 7.4
- DeepL free
- composer
Additional context / Optional solution
public function translateContent(
string $content,
array $targetLanguageRecord,
string $customMode,
array $sourceLanguageRecord
): string {
$content = htmlentities($content);
// mode deepl
if ($customMode == 'deepl') {
$response = $this->deeplService->translateRequest(
$content,
$targetLanguageRecord['language_isocode'],
$sourceLanguageRecord['language_isocode']
);
if (!empty($response) && isset($response['translations'])) {
foreach ($response['translations'] as $translation) {
if ($translation['text'] != '') {
$content = htmlspecialchars_decode($translation['text'], ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5);
break;
}
}
}
}
Adding $content = htmlentities($content);
solved the issue and the formatting stays the same.
I could XClass this as a solution for now, but i would like to have this fixed in the extension itself. It might not be the correct location for the fix, but anywhere you prefer.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working