Unify translate operations over AI
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3478721. -->
Reported by: [valthebald](https://www.drupal.org/user/239562)
Related to !210
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p><span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/ai/issues/3459977" title="Status: Closed (fixed)">#3459977: Discuss: Translation operator type</a></span> has introduced a new operation type "Translate text". Since this is a new operation, other translation-related parts (ai_translate, translate plugin of ai_ckeditor) use "Chat" operation, which exists for a long time.</p>
<p>As a result, there are at least 3 places to configure translation-related parameters:</p>
<ol>
<li>Translate text provider in AI settings (no bundled provider supports the new operation at the moment)</li>
<li>AI translate settings (twig-based prompt that can be altered by third parties)</li>
<li>Hard-coded translation prompt in CKEditor translate plugin</li>
</ol>
<p>This may confuse both users and developers.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Have a single "point of responsibility" for translation purposes. This point should</p>
<ol>
<li>Have "text to translate" as a single required input</li>
<li>Have a set of translation contexts (from and to languages in the form of ISO code or free name, provider id, contexts provided/altered by third parties) as an optional parameter</li>
<li>Have "translated text" as output</li>
</ol>
<p>Location of this point of responsibility is TBD</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>Decide what "translation point of responsibility" is. A service? A trait that can be then used by AI providers? AiProviderClientBase methods?</p>
<p>If it's a service, then what module this service belongs to (ai or ai_translate)? In case it's ai_translate, module description in ai_translate.info.yml should be changed from "one click translation" to "translation-related functionality"</p>
> Related issue: [Issue #3481001](https://www.drupal.org/node/3481001)
issue