Translation batch process does not handle translation errors

Created on 19 August 2025, about 2 months ago

Problem/Motivation

Currently, translation errors are not handled at all.
Errors are collected during the batch process, but they are never used or displayed.

Fields are translated one by one using a batch operation. Some of these translations may fail, but the user has no way of knowing which ones failed. In some cases, every field translation can fail, yet the translation entity is still created and saved with the original (untranslated) data. This leads to confusion and potentially incorrect content being stored.

Steps to reproduce

1. Create a piece of translatable content with multiple fields.
2. Trigger a translation (e.g., via the batch translation process).
3. Cause one or more fields to fail during translation (e.g., by simulating an API failure, invalid configuration, or unsupported field type).
4. Observe that:
- The translation still gets created, even if all fields fail.
- No error message is shown to the user.
- The user cannot know which fields failed.

Proposed resolution

- Add a new batch operation to check if any errors occurred during the `translateSingleField` batch operation.
- If errors are found, display a message to the user specifying that some fields failed to translate.
- In the `insertTranslation` step, check if all fields failed:
- If all failed, do not create a translation at all.
- Instead, show a clear error message to the user.

Expected result

- Users are notified when translation errors occur.
- Partial translations are more transparent, as users know which fields failed.
- Fully failed translations are prevented from being created, avoiding invalid or misleading translation entries.

Steps to reproduce (required for bugs, but not feature requests)

Please provide information like AI modules enabled, which AI provider, browser, etc.

📌 Task
Status

Active

Version

1.1

Component

AI Translate

Created by

🇬🇪Georgia IliaNoz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @IliaNoz
  • @ilianoz opened merge request.
  • 🇧🇬Bulgaria valthebald Sofia

    @IliaNoz: any reason you changed the target version from 1.2.x to 1.1.x?

  • 🇧🇪Belgium svendecabooter Gent

    Setting back to 1.2.x as the correct branch to target.

    I tried reproducing this, as I had earlier experienced weird behavior when I had connection problems to my AI API endpoint.
    However, in my testing, I get into \Drupal\ai_translate\Plugin\AiProvider\ChatTranslationProvider::translateText(), and into the GuzzleException catching. This then logs the error, but proceeds to return an empty translated text output.

    This finally results into database errors trying to save the translation, and the display of the message "There was some issue with content translation.".

    So the scenario above might be a separate use case that could be taken into account for improving the error message output.
    The error message should be more clear, and a translation should not be attempted to be created I guess?

Production build 0.71.5 2024