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

CommentFileSizeAuthor
Screen Shot 2017-03-14 at 12.01.27.png45.36 KBmbovan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mbovan created an issue. See original summary.

Peacog’s picture

Another 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

Berdir’s picture

Priority: Normal » Major