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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

Berdir’s picture

Status: Active » Needs review
FileSize
1.38 KB

The 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..

Status: Needs review » Needs work

The last submitted patch, 2: webform-translation-elements-2981674-3.patch, failed testing. View results

jrockowitz’s picture

The 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.

jrockowitz’s picture

Here are steps to reproduce the issue...

  • Install Drupal and Webform in English
  • Enable Configuration translation (/admin/modules)
  • Setup Spanish (/admin/config/regional/language)
  • Add Spanish translation to the Contact webform (/form/contact)
  • Edit and save Contact webform (/es/admin/structure/webform/manage/contact)
  • Confirm that the English form is overwritten.
jrockowitz’s picture

Status: Needs work » Needs review
FileSize
6.55 KB

The 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.

jrockowitz’s picture

Okay, I figure out the Ajax issue.

jrockowitz’s picture

I 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.

Berdir’s picture

Wasn'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?

  • jrockowitz committed 43f79a0 on 8.x-5.x
    Issue #2981674 by jrockowitz, Berdir: Confusing UI when a webform...
jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.