Problem/Motivation
We've seen very strange behavior with a webform on a client site, it always seemed to lose translations, or more correctly, the translations were overwriting the source.
I thought it's related to #2913548: Source element values are replaced with translated values, and it maybe kind of is, or maybe those issues are related to this but the real problem seems to be in initElements(), which explicitly loads the translations and applies them.
I don't understand what why that exists, it apparently was added in #2873270: Webform Lingotek Integration, but among other things, it breaks the whole concept of override free loading.
The result is that the UI shows you the message "You are editing the original English language for this webform.", but actually, it is displaying the translated elements, and if you save then, the english original is gone.
Proposed resolution
Remove it? Not sure what will happen, but I'll provide a patch and then we'll see if that fails.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#7 | 2981674-7.patch | 6.89 KB | jrockowitz |
| |||
#7 | interdiff-2981674-6-7.txt | 1.01 KB | jrockowitz |
#6 | 2981674-6.patch | 6.55 KB | jrockowitz |
| |||
#2 | webform-translation-elements-2981674-3.patch | 1.38 KB | Berdir |
Comments
Comment #2
BerdirThe lingotek issue reference wasn't correct, that just adjusted it slightly and the whole thing is necessary to merge things together properly.
This uses the admin path context, but that just fixes it in some cases like the UI but not update path functions, where we're back to the other issue and I don't think the core issue can solve it on its own.
The main issue is that the config entity doesn't know whether it was loaded as override free, which is part of what the core issue (#2910353: Prevent saving config entities when configuration overrides are applied) is addressing to solve its own problem, so once we have that, we could rely on that..
Comment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedThe patch for #2913548: Source element values are replaced with translated values was experimenting with throwing an error when a webform is about to be corrupted.
I probably need to review and better document how the webform module is handling translating elements.
Comment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedHere are steps to reproduce the issue...
Comment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedThe attached patch targets webform specific admin routes.
The only issue I can't figure out is the Ajax callbacks on /es/admin/structure/webform/manage/WEBFORM_ID are refreshing and translating the webform.
Comment #7
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedOkay, I figure out the Ajax issue.
Comment #8
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI manually retested this patch and Drupal\webform\Tests\WebformEntityTranslationTest is working fine.
A somewhat unrelated but troubling issue is when I enable the webform_test_translation.module the Spanish translation for the test_translation webform is not being imported. What is confusing is that the WebformEntityTranslationTest is enabling webform_test_translation.module and Spanish translation for the test_translation webform is fine.
Still, I am open to committing this patch since it does fix this ticket's main issue.
Comment #9
BerdirWasn't able to test this yet. In the specific project, we switched the language of that one problematic form now as a workaround for this.
Any improvement helps and it has test coverage, so committing it shouldn't hurt, maybe leave a todo on the other related webform/core issue, because once there is an actual API to check if an entity was loaded with or without overrides should be much more reliable, also during updates and so on?
Comment #11
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented