When translating HTML content (e.g. paragraph text fields), the translateHtmlWithSafeTextExtraction() method in Utility.php has a hardcoded 'google' provider on line 2215, ignoring the configured translation provider. This means that even when DeepL or another provider is selected in the module settings, all HTML content is silently translated via Google Translate. Only plain text fields are correctly routed to the configured provider.

https://git.drupalcode.org/project/auto_translation/-/blob/1.0.x/src/Uti...

```
$translated = $this->callProviderTranslationApi($segment['text'], $s_lang, $t_lang, 'google');
```

CommentFileSizeAuthor
#3 3573131-3.patch2.73 KBdejan0
#2 3573131-2.patch683 bytesdejan0
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dejan0 created an issue. See original summary.

dejan0’s picture

StatusFileSize
new683 bytes

Quick fix: replaced the hardcoded 'google' provider in translateHtmlWithSafeTextExtraction() (line 2215) with the configured provider from config

dejan0’s picture

Status: Needs work » Needs review
StatusFileSize
new2.73 KB

Alternative fix: instead of reading the provider from config at the call site, this patch propagates the $provider parameter through the entire HTML translation chain. This is a cleaner approach as it avoids duplicating the config read logic and keeps the provider flow consistent with how translatePlainText() already works. This patch touches more methods, so it may need additional testing across different providers and content types.

bigbabert’s picture

Hi @dejan0,

thanks to report and provide patch, i'll review and include in next versions.

Thanks

angel_devoeted’s picture

Tested on Drupal 11.4-dev (Drupal Forge) with 1.4.37 and 3573131-3.patch applied.

I verified via logs that HTML content (formatted text, including a Paragraphs text field) is translated using the configured provider. In my case, both HTML and plain text fields triggered DeepL as expected.

bigbabert’s picture

Status: Needs review » Reviewed & tested by the community

bigbabert’s picture

Status: Reviewed & tested by the community » Fixed

released in 1.4.38

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

bigbabert’s picture

Status: Fixed » Closed (fixed)