Problem/Motivation
We have worked through improving the consistency and cleanness of the APIs to handle translations and separated local and target languages more. A translator plugin now does not need to care about mappings.
However, the sources always just receive a job item to saveTranslation.
Based on this, all sources need to correctly lookup the job from the item and then identify the language by $this->getJob()->getTargetLanguage().
This similarly contains risk of doing it wrong.
Proposed resolution
Additionally pass the target language code (and the data) into the saveTranslation() as arguments.
That reduces the source plugin code by at least 2 lines and more explicitly tells the source plugin what to do.
API changes
Two new arguments on saveTranslation
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | interdiff-pass_target_language-2569643-2-6.txt | 6.03 KB | edurenye |
| #6 | pass_target_language-2569643-6.patch | 5.62 KB | edurenye |
| #2 | pass_target_language-2569643-2.patch | 6.11 KB | edurenye |
Comments
Comment #2
edurenye commentedDone.
Comment #3
edurenye commentedComment #4
berdirtype everywhere (tarjet).
Wondering how a tar jet would look like now ;)
Well, at least you are consistent ;)
That's not correctly structured. And duplicated.
Also, not 100% convinced about this. I can kind of see the point on target language, since they need that and this makes that easily available. But data? Is passing that in as an argument really that much easier? It's just $job_item->getData(), where you can also look up the documentation for it IIRC, while we'd either have something useless or duplicated on the $data argument.
Comment #5
miro_dietikerOK you are right, i was possibly thinking too far..
I mean, you could also get the info from the item, that you should ask for the right target language... ;-)
I thought if we already pass the info to the API about what target language to save, we can also pass the data at the same time.
Then, if ever we make the job_item work different and possibly even support multiple target languages, the API would stay and the source can cleanly save the specific translation.
...But i'm pretty sure you will kill this direction of thought immediately. ;-P
Comment #6
edurenye commentedSorry for that misspelling error.
I changed that and deleted data in the calls.
Comment #7
giancarlosotelo commentedComments were addressed and the patch looks good. tmgmt its broken now but I think it could be rtbc.
Comment #9
berdirFixed.