AI Translate settings are not sufficient

Created on 3 September 2025, 10 days ago

Problem/Motivation

The AI Translate functionality basically works. But for more complex websites it is not useful as it is.
At the moment it only offers a single prompt per language. But the prompt needs to be different for different contexts:

  • optional prompt per content type / bundle
  • optional prompt per translatable field
  • different provider per bundle or field
  • optionally disable translation per field

For example, you might automatically accept translations for the title and the body field, but you won't AI translations for the path alias.
Or you want to specify a different context like "food" or "computers" to get Apple translated correctly.

Some providers might be better suited for specific contexts or languages than others.

Furthermore, the token replacement is not sufficient. For example, if a content entity references a manufacturer entity, I want to add the instruction to the prompt that the manufacturer's name stored in a field of that entity must not be translated. Good examples are Zebra or Star or Brother.

In general it would be good to have access to the taxonomy terms assigned to an entity to provide more information about the context.

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

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

Proposed resolution

Remaining tasks

Decide if such a functionality has to go into this module itself or if the API is sufficient to offload it into a 3rd party module.

Optional: Other details as applicable (e.g., User interface changes, API changes, Data model changes)

Feature request
Status

Active

Version

2.0

Component

AI Translate

Created by

🇩🇪Germany mkalkbrenner 🇩🇪

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

Comments & Activities

  • Issue created by @mkalkbrenner
  • 🇧🇪Belgium svendecabooter Gent

    Those seem like some valid points and good improvements to the AI translation system to me.
    To implement some of those, some major refactoring might be needed to the AI Translate system, so not sure if they would all be easily doable.

    Currently the field data gets extracted from the entity, based on the field type of each field.
    The 3rd party settings available on a field could be leveraged to configure this some more.
    E.g. the ReferenceFieldExtractor plugin already does this, to decide whether to translate a certain entity_reference field or not.
    Extending this with the option to "optionally disable translation per field" seems fairly doable.

    An optional prompt per field is something that would need to be passed along in the metadata of the extracted field values, towards the TextTranslator service. This should also be possible, but would complicate the already somewhat complex array structure of this even more.

    Switching providers per field would work in the same way. Actually the \Drupal\ai_translate\TextTranslator::translateContent() method already has a context array parameter implying in the documentation that should be possible, but the implementation code doesn't do anything with it.

    We should probably provide a decent framework where configurable context can get passed along during the translation pipeline (text extraction, AI service calling, translation saving), and more events get triggered, so other contrib modules could plugin into that and provide extra tools - if not provided with the ai_translate module itself.

    I think this request should probably need some more analysis, and be split out into separate subtasks.

  • 🇩🇪Germany mkalkbrenner 🇩🇪

    Thanks for considering this.
    To get things going, I started working on another contrib module on top of ai_translate.
    Maybe we could treat that one as incubator and intermediate solution before moving parts back into ai_translate.
    I'll publish that module as soon as the basic stuff is working.

  • 🇩🇪Germany mkalkbrenner 🇩🇪

    BTW, one it is working, I consider to enhance search_api_clir to use it.

Production build 0.71.5 2024