RuntimeException: Translator not set when translating document in batch
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3546930. -->
Reported by: [idebr](https://www.drupal.org/user/1879760)
Related to !53
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>When a job includes a document translation, the following error may occur depending on the order the batch operations are executed:</p>
<p><code>RuntimeException: Translator not set. in Drupal\tmgmt_deepl\DeeplTranslatorApi->getTranslator() (line 68 of /[...]/htdocs/modules/contrib/tmgmt_deepl/src/DeeplTranslatorApi.php).</code></p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>Set up a job that includes a document to be translated:</p>
<p>Stack trace:</p>
<pre>#0 /[...]/htdocs/modules/contrib/tmgmt_deepl/src/DeeplTranslatorApi.php(108): Drupal\tmgmt_deepl\DeeplTranslatorApi->getTranslator()<br>#1 /[...]/htdocs/modules/contrib/tmgmt_deepl/src/DeeplTranslatorBatch.php(87): Drupal\tmgmt_deepl\DeeplTranslatorApi->translateDocument()<br>#2 /[...]/htdocs/core/includes/batch.inc(297): Drupal\tmgmt_deepl\DeeplTranslatorBatch->translateDocumentOperation()<br>#3 /[...]/htdocs/core/includes/batch.inc(139): _batch_process()<br>#4 /[...]/htdocs/core/includes/batch.inc(95): _batch_do()<br>#5 /[...]/htdocs/core/modules/system/src/Controller/BatchController.php(52): _batch_page()<br>#6 [internal function]: Drupal\system\Controller\BatchController->batchPage()</pre><h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Ensure the translator is set when translating documents, similar to translating text.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<ol>
<li>Write a merge request</li>
<li>Review</li>
<li>Commit</li>
</ol>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>None</p>
<h3 id="summary-api-changes">API changes</h3>
<p>None</p>
<h3 id="summary-data-model-changes">Data model changes</h3>
<p>None</p>
issue