Translation memories and glossaries settings are not passed to the Lara Translate API
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3588153. -->
Reported by: [robertoperuzzo](https://www.drupal.org/user/2661375)
Related to !10
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>The Lara Translate provider settings UI allows users to configure both translation memories (adaptTo) and glossaries, but neither is passed to the Lara Translate API<br>
during translation requests.</p>
<p>In LaraTranslator::translateText() (line 685–704), the TranslateOptions object is built, but:</p>
<p> 1. Translation memories — The UI saves the setting at path ['memories', 'adaptTo'] (LaraTranslatorUi.php line 459), but the code reads from ['translation_options',<br>
'adaptTo'] (line 688). The paths don't match, so the value is always NULL.<br>
2. Glossaries — The UI saves the setting at path ['glossaries_section', 'glossaries'] (LaraTranslatorUi.php line 491), but translateText() never reads or passes<br>
glossary IDs to TranslateOptions::setGlossaries() at all.</p>
<p>This means terminology enforcement (glossaries) and style adaptation (memories) do not work regardless of what the user configures.</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p> 1. Navigate to /admin/config/regional/tmgmt_translator/manage/lara_translate<br>
2. Under "Translation Memories", select one or more memories<br>
3. Under "Glossaries", select one or more glossaries<br>
4. Save the translator configuration<br>
5. Request a translation for any content<br>
6. Observe that the translated text does not respect glossary terms nor adapt to the selected memories — neither is sent to the API</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Fix LaraTranslator::translateText() to read settings from the correct paths and pass them to TranslateOptions:</p>
<pre> // Set adapt_to option if configured.<br> $adapt_to = $tmgmt_translator->getSetting(['memories', 'adaptTo']);<br> if ($adapt_to !== NULL && is_array($adapt_to)) {<br> $memory_ids = array_values(array_filter($adapt_to));<br> if ($memory_ids !== []) {<br> $options->setAdaptTo($memory_ids);<br> }<br> }</pre><pre> // Set glossaries if configured.<br> $glossaries = $tmgmt_translator->getSetting(['glossaries_section', 'glossaries']);<br> if ($glossaries !== NULL && is_array($glossaries)) {<br> $glossary_ids = array_values(array_filter($glossaries));<br> if ($glossary_ids !== []) {<br> $options->setGlossaries($glossary_ids);<br> }<br> }</pre><h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p> - Fix the settings path for adaptTo from ['translation_options', 'adaptTo'] to ['memories', 'adaptTo']<br>
- Add setGlossaries() call using the ['glossaries_section', 'glossaries'] setting<br>
- Add/update unit test coverage verifying both options are passed to TranslateOptions<br>
- Verify end-to-end that the Lara API receives the correct memory and glossary IDs</p>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>None — the UI already supports memory and glossary selection. This fix wires them to the API call.</p>
<h3 id="summary-api-changes">API changes</h3>
<p>None — the Lara SDK already supports TranslateOptions::setAdaptTo() and TranslateOptions::setGlossaries(). The module simply needs to call them with the correct<br>
setting paths.</p>
<h3 id="summary-data-model-changes">Data model changes</h3>
<p>None.</p>
issue
GitLab AI Context
Project: project/tmgmt_laratranslate
Instance: https://git.drupalcode.org
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://git.drupalcode.org/project/tmgmt_laratranslate/-/raw/2.0.x/README.md — project overview and setup
Repository: https://git.drupalcode.org/project/tmgmt_laratranslate
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD