Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Many continuous translator plugins (Google, Microsoft, Acclaro, Thebigword) implement
TranslatorPluginInterface::requestTranslation(JobInterface $job)
in a way to delegate translation call to the ContinuousTranslatorInterface::requestJobItemsTranslation(array $job_items)
implementation by passing an array of job items to translate.
requestJobItemsTranslation()
can change behaviour of the job (e.g. changing the state to rejected because a remote project/order failed to be created)requestTranslation()
fails to pick-up those changes which can end up in something like:
The reason for second is that requestJobItemsTranslation()
gets a new instance of the job (from a job item) while requestTranslation()
deals with an old object.
Proposed resolution
Possible solutions:
- Translator plugins could reload the job entity to get the updated state
requestJobItemsTranslation()
could accept$job
as a method parameter (This is an API change)requestJobItemsTranslation()
could return$job
object (Still an API change?)- ...
Remaining tasks
User interface changes
API changes
Possible ContinuousTranslatorInterface::requestJobItemsTranslation(array $job_items)
signature change.
Data model changes
Comment | File | Size | Author |
---|---|---|---|
Screen Shot 2017-03-14 at 12.01.27.png | 45.36 KB | mbovan |
Comments
Comment #2
Peacog CreditAttribution: Peacog as a volunteer commentedAnother consequence of this is that translation providers that auto accept translations cannot know whether or not the translation was finished.
For example, when TMGMT Translator Microsoft is configured to auto accept translations, the jobs are never marked 'finished' (at least they are marked finished by TMGMT, but the state is subsequently changed back to submitted by TMGMT Translator Microsoft). This means that the jobs will never be purged. On a large site that does lots of automatic translations the tmgmt tables in the database can quickly get very big.
For the Microsoft provider I've rolled a patch that implements solution 1 i.e. reloading the job to get its current state. See #2926085: Auto accepted translations are never finished
Comment #3
Berdir