By svendecabooter on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
1.4.x
Introduced in version:
1.4.5
Description:
When AI Context 1.0.0-beta5 or later is enabled, AI Translate registers a Translate consumer type with one consumer, translate:default. Context items can then be pushed into the system prompt of translations. AI Translate does not depend on AI Context; without it nothing changes.
Push is off by default. To use it:
- Enable AI Context and rebuild caches.
- Go to Context Control Center > Context consumers, edit AI Translate and check Push context automatically.
- Make sure the Translation operation uses the Chat proxy to LLM provider.
The AI Translate settings form (/admin/config/ai/ai-translate) shows whether push is on and links to the consumer.
Limitations
- Only translations through Chat proxy to LLM receive context. Other dedicated translation providers don't.
- The Translate tab, Drush and interface translation all share the one
translate:defaultconsumer. - Context is added to every field separately, since each field is its own chat request. This raises token use per translated entity.
- Drush, cron and queue runs as anonymous get no context items, because item access fails closed. Run Drush with
--userwhen context is needed. - Items limited to a language are not yet filtered by the target language of the translation.
Cached translations
Only relevant when Cache translation results is enabled. Translations saved on content are never touched.
- While push is off, the cache works as before.
- Turning push on starts a separate cache, so translations cached earlier are not reused. Turning it on or off, or changing context items or AI Context settings, invalidates cached translations.
- While push is on, each content item gets its own cached translation, so the same text on several items means several provider calls.
- A cached translation skips the provider, so no context is pushed and no AI Context usage is recorded for it.
- The cache does not vary by user. A translation cached by an anonymous run, which got no context, is reused for later runs by editors. The same goes for items limited by the Roles scope. Run Drush with
--user, or rebuild the cache after an anonymous run. - The Translate consumer type has a Share cached translations across content while context is pushed option to keep one cached translation per text. Only enable it if no context item depends on the content being translated (Entity Types, Taxonomy or Specific Entities scopes). Otherwise a translation made for one item can be saved to another.
Developer changes
EntityTranslationOrchestratorInterface::translateTextMetadataItem()has a new optional fourth parameter,array $entityContext = []. Callers are not affected. Classes implementing the interface must add the parameter to their signature.- Chat-proxy requests carry
entity_context(entity_type,bundle,id) andlanguage_context(target, andsourcewhen known) as request metadata on theChatInput. This requires an AI module version with request metadata support. - Code calling
TextTranslatorInterface::translateContent()directly can pass anentity_contextkey in$context, so entity-scoped context items match. TextTranslatorhas a new optional constructor argument (the AI Context selection factory), and the protectedcacheId()has a new optional$contextparameter. Subclasses overridingcacheId()should pass it on.
Impacts:
Site builders, administrators, editors
Module developers