Basically we need it for this issue in tmgmt_memory #2729873: Create a hook to translate exact matches on submission so this module can translate it before sobmiting it to the translator or even skip job_items or data_item, but could be used for any other module, to add fields or remove them if needed or modify the data items for any other reason.
To do that we will add a hook before the request translation (If need to modify data) and another after (If need to revert changes or add more changes).
Also we also will add a flag in Job that will be set to TRUE while we request a translation, also in getItems if we are requesting a translation and a jobItem does not have pending data_items we will not return this item.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | interdiff-add_hooks_to_alter_the-2731939-5-8.txt | 4.54 KB | edurenye |
| #8 | add_hooks_to_alter_the-2731939-8.patch | 6.8 KB | edurenye |
| #5 | interdiff-add_hooks_to_alter_the-2731939-2-5.txt | 937 bytes | edurenye |
| #5 | add_hooks_to_alter_the-2731939-5.patch | 5.66 KB | edurenye |
| #2 | add_hooks_to_alter_the-2731939-2.patch | 5.8 KB | edurenye |
Comments
Comment #2
edurenye commentedDone.
Comment #3
edurenye commentedComment #5
edurenye commentedFixed, we need to open a issue to make request translation return the state as says the documentation.
Comment #6
edurenye commentedOpened that issue #2754231: Incoherence between documentation and behavior in requestTranslation.
Comment #7
berdirNo need for $all_items? You could also use array_filter to simplify this:
$items = array_filter($items, function (JobInterface $item) { $item->getCountPending() > 0; }));
Needs comments to explain those lines.
Same here
Not a big fan of the requestingTranslation flag but I don't really have any better ideas. I think we need to find a better name however, instead of naming it after the context, lets name it after what we use it for. $this->filterTranslatedItems maybe? Should require less comments to explain what it is for.
We should also add @see documentation to the two hooks we're calling on requestTranslation and possibly also mention this concept on the translator requestTranslation() method docs, something along the lines of "During the translation process, Job::getItems() will only return job items that are not already fully translated.".
Comment #8
edurenye commentedDone all those changes.
Comment #10
edurenye commentedComment #12
berdirThat's what I meant.
Edit: Forgot to mention, .. committed :)