While debugging the reject handling, we noticed today that implements a thing that they call Lazy-Loading. Which is very weird name for something that is basically a translation cache. If you submit a translation job with a text that was already translated once (for you, I guess, not everyone) then the translation is immediately returned with status available and no job is created on the server.
We need to handle this by removing the tier == 'machine' check in the requestTranslation() call and instead only check that status is either approved or available in retrieveTranslation() (which we should rename to saveTranslation(), it doesn't retrieve anything, unlike others like Nativy).
Comments
Comment #1
blueminds CreditAttribution: blueminds commentedTo actually be able to test the available status tests had to be reworked. So quite a bit of changes are made there.
Also in case we receive an available translation for an item that is already translated, we log an error message.
Comment #2
BerdirLooks good, I haven't followed the whole discussion about available/multiple callbacks that you had with Miro but I don't quite understand why it's necessary, see below.
Can you explain why this is only done for status available and not approved?
Also, I don't really understand the reason for this. Isn't status available used only as an immediate response? I don't think the callback will ever be called with available, because if it would have been available, then it would have already been returned directly as a response to the request. I don't think the newer v2 API handles it differently, either.
Why is this removed?
See above, I don't think available is ever used for the callback.
Instead, I suggest you mimick th real behavior by using a special #text, e.g. "Force available status" that then uses available for the immediate response.
Create yet instead of Yet create.
Comment #3
blueminds CreditAttribution: blueminds commentedI have implemented all your comments.
Regarding the available status - it is technically possible :) That is why this use case is handled. But I see your point. So we might keep it just to cover the use case, or we can just remove it to prevent future confusion of type "what does this do?". So anyway, I think the confusion is bigger deal than the one that we "might" receive such response. Therefore I removed it as it does not really bring a value.
Comment #4
blueminds CreditAttribution: blueminds commentedeh... wrong patch, sorry
Comment #5
BerdirRemoving sounds fine to me.
Looks good, confirmed that the tests work locally, just one more thing then we're done :)
As I said, I suggest to rely on a specific #text to identify this. something like '#text' => 'Lazy-Loading available' and then check body_src here. That is basically the same as what mygengo does. Relying on a custom tier wouldn't work when doing UI tests because the select has a fixed set of options and it's not possible to add more from the client side.
Minor, but when you're at it.. "Else" => "Otherwise".
Comment #6
blueminds CreditAttribution: blueminds commentedPlease see the patch. BTW, its cool that by your patch reviews one also learns English ;)
Comment #7
BerdirLearning english: At your service :)
Loos good. Tests are green, commited!