Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#5 | 2965060-6.patch | 2.08 KB | jrockowitz |
| |||
#5 | User interface translation Webform Demo Site.png | 139.91 KB | jrockowitz |
#4 | Edit Spanish translation for Job Application webform Webform Demo Site.png | 365.07 KB | jrockowitz |
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #3
DakwamineAdded link to the webform template in description.
Comment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedTo 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.
Comment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedThe 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.
Comment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #7
DakwamineThank 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.
Comment #9
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@Dakwamine Thanks for noticing this issue.
I committed the patch and you can download the latest dev release to review.
Comment #10
Dakwamine@jrockowitz Just tested it. It works like a charm. Thank you for fixing this issue!
Comment #12
joseph.olstadnoticed 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.
Comment #13
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@joseph.olstad Please create a new ticket and document the issue.
Comment #14
joseph.olstad@jrockowitz, here is the issue.
If you need assistance with this, let me know.