Description
If you have a Markup component in a webform and set its "Display on" setting to "Both form and viewed submission", the Markup component will get translated on the form itself, but it will not get translated (1) when sent by email, or (2) when viewing a submission's result page.
How to reproduce
1. Create a webform, and add Markup component field. Enter some text in the Value field, e.g. "My string to be translated" and then set the "Display on" option to "both form and viewed submission". You may also want to add some random text fields to compare.
2. In the email section, have it send an email to yourself with the template "[submission:values]".
3. In the webform's form settings, select "Expose webform component strings suitable for translation" and "Keep a single webform across a translation set".
4. Go to Configuration > Translate interface > Strings, select "Webform Localization" and refresh its strings.
5. Switch to the tab Translate and search for the string you used in the Markup component (e.g. "My string to be translated"). Translate it. Translate any other components your form may have.
6. View your form in the other language. The Markup component appears translated.
7. Click on the submission button. Result: You'll receive an email with the Markup component ("My string to be translated") still in the original language, while all other fields you may have will be translated.
8. View the submission through the backend Results page. Switch languages and observe the Markup component. Again, it's still in the original language, while all other fields you may have will be translated.
Any ideas why this is?
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | webform-markup_translation-2728557-10.patch | 1008 bytes | joseph.olstad |
Comments
Comment #2
joel_osc commentedHi, I think the problem may be in the webform markup component display code. I have a patch that we can get the webform maintainers to look at to see if it is correct and reasonable. The patch aligns the markup component display code with the markup component render code which enables webform_localization to just work.
If the webform maintainers don't agree with the approach then we can look at putting some code into webform_localization to determine if it is being called on render or display and then handle it appropriately. To me this seems like a bit of a hack, but we will see. It depends on whether my patch to webform markup is too risky or just plain wrong - which is could very well be.
If you could test the patch to get us a little more test coverage that would be great. Cheers.
Comment #3
zread commentedHi @joel_osc, I've been able to test your patch on my end and can confirm that it works for both scenarios mentioned in the lead (i.e. when sent by email, and when viewing a submission's result page).
Comment #4
joseph.olstadrtbc +1 Thanks Joel
Comment #5
liam morlandIs this supposed to be an assignment or should it be
===?@joseph.olstad If you are declaring it RTBC, please set the status.
Comment #6
joseph.olstadYes in that case it appears that it should probably be == or === usually == and not =
Unless of course the assignment was intentional,
Joel, want to weigh in?
Comment #7
joel_osc commentedDefinitely an error!
Comment #8
liam morlandPlease post a corrected patch. If you can, please add tests, in particular, a test that would catch the = instead of ==.
Comment #9
fgjohnson@lojoh.ca commentedHey Joseph,
Would this patch render the translated Labels on the Preview page of a Form when using Webform_workflow?
We are also using webform_matrix_component... And that's where the problem lies!
We have applied it, but this is still a problem.
The Labels of the components are fine whilst filling out the form... but on the preview the English labels are rendering (the french labels exist when looking at devel... but not rendering on the page.
Comment #10
joseph.olstadComment #11
fgjohnson@lojoh.ca commentedThanks Joseph,
Patch applies with no errors.
BUT Doesn't resolve the display of headings from webform_matrix_component....
See related ticket in the issue queue for WMC.
https://www.drupal.org/node/2877028
Seems to work well.Drupal 7.54
PHP 5.5.9-1ubuntu4.21
MySQL 5.5
Webform Module -> 7.x-4.15 (and prior)
Webform Matrix Component -> 7.x-4.27 (and prior)
Comment #12
liam morlandWhy does this patch rename #value to #markup? Is that needed to make translation work? I am concerned that anyone with a custom theme_webform_display_markup() will have their function no longer work.
I note that the documentation for _webform_display_component() states that #value is required; with this patch, #value is no longer there.
Comment #13
chris matthews commentedThe latest patch in #10 to markup.inc still applies cleanly to the latest 7.x-4.x-dev. However, Liam Morland's last comment in #12 was...
Comment #14
liam morlandDrupal 7 is no longer supported. If this applies to a supported version, please re-open.