- Issue created by @szeberli
- 🇩🇪Germany SteffenR Germany
Thanks for the finding. The issue is caused by a missing exception handling in the batchRequestTranslation callback.
We need to improve the exception handling in the batchRequestTranslation callback.
The self::doRequest needs to be wrapped into a try/ catch block.try { $result = self::doRequest($job, $query_params); // Collect translated texts with use of initial keys. foreach ($result['translations'] as $translated) { $translation[$keys_sequence[$i]]['#text'] = rawurldecode(Html::decodeEntities($translated['text'])); $i++; } if (isset($context['results']) && isset($context['results']['translation']) && $context['results']['translation'] != NULL) { $context['results']['translation'] = array_merge($context['results']['translation'], $translation); } else { $context['results']['translation'] = $translation; } $context['results']['i'] = $i; } catch (TMGMTException $e) { \Drupal::messenger()->addError($e->getMessage()); }
To overcome issues of incomplete translations in case of an error, the actual translation job needs to be resetted or deleted (needs to be evaluated) in the batchFinished callback.