I have some default webform templates from the webform module which were translated (automatically, I guess?). The thing is that the job application template contains HTML markup, more specifically div ones, like so:

elements: |
  ...
  resume:
    '#title': 'Your Resume'
    '#type': fieldset
    resume_method:
      '#type': radios
      '#options':
        attach: 'Attach resume file'
        paste: 'Paste your resume'
      '#prefix': '<div class="container-inline">'
      '#suffix': '</div>'
      '#default_value': attach
  ...

And if you try to save translations from the /admin/config/regional/translate UI, Drupal prevents this by returning an error:

The submitted string contains disallowed HTML: information: '#title': 'Your Information' '#type': fieldset first_name: '#title': 'First Name' '#type': textfield '#required': true last_name

etc...

Resources

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dakwamine created an issue. See original summary.

jrockowitz’s picture

Version: 8.x-4.x-dev » 8.x-5.x-dev
Dakwamine’s picture

Issue summary: View changes

Added link to the webform template in description.

jrockowitz’s picture

To translate a webform you should go directly to the 'Translate' tab. (/admin/structure/webform/manage/template_job_application/translate/es/edit)


I don't think we can fix this UI translation issue without causing unintended side-effects, basically allowing users to entered unexpected HTML markup into translated strings.

jrockowitz’s picture

The attached patch stops Webform YAML from being translated via the 'User interface translation' (/admin/config/regional/translate). This prevents the validation error and provides a little more direction.

jrockowitz’s picture

Status: Active » Needs review
Dakwamine’s picture

Thank you jrockowitz. I will test it some time after but I already like the notice in the translation UI which is quite elegant regarding the user experience.

And thank you for the explanation about where to translate those webforms.

  • jrockowitz committed c63dbd3 on 8.x-5.x
    Issue #2965060 by jrockowitz: Cannot save translation value in /admin/...
jrockowitz’s picture

Status: Needs review » Fixed

@Dakwamine Thanks for noticing this issue.

I committed the patch and you can download the latest dev release to review.

Dakwamine’s picture

@jrockowitz Just tested it. It works like a charm. Thank you for fixing this issue!

Status: Fixed » Closed (fixed)

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

joseph.olstad’s picture

noticed similar issue but for twig field in the webform_submission email template

did not get the helpful tip about "webforms can only be translated via the Webform's configuration translate tab"

Seems like the patch logic above didn't catch twig fields.

jrockowitz’s picture

@joseph.olstad Please create a new ticket and document the issue.

joseph.olstad’s picture