Problem/Motivation
When I create a translation for a web form, usually the CKEditor is shown also in the translation form of fields entered with CKEditor, e.g. text fields. However, when defining a "Custom body" in an email confirmation/notification with CKEditor (which is actually the only choice), the respective element in the translation form is shown as a plain text field with the source code.
Translation of the emails is therefore tricky for translators not aware of HTML code, and who are otherwise already used to work in CKEditor fields.
Steps to reproduce
- Install webform and a language for translations
- For example, in the contact form, go to Settings - Email/Handlers, edit one of them, under Message, select "Custom body", enter some formatted text in the CKEditor
- In the same webform, go to Translate, edit/add any language, under Webform Handlers, open Email...mapping, open Email: the Email body source text is displayed in a plain text field only
Proposed resolution
Enable CKEditor in the translation of the Email body text, if it is a "Custom body"
Comment | File | Size | Author |
---|---|---|---|
#9 | 3202515-9.patch | 7.13 KB | jrockowitz |
#8 | 3202515-8.patch | 5.2 KB | jrockowitz |
#3 | 3202515-3.patch | 3.21 KB | jrockowitz |
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI am almost certain this proved to be really difficult to do because it is impossible to track when an email handler was being translated.
Comment #3
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI stand corrected. Here is a POC but it is going to need a lot of improvements.
I am might learn toward adding a
::alterTranslationConfigForm
method to the\Drupal\webform\Plugin\WebformHandlerInterface
Comment #4
alexh CreditAttribution: alexh commentedThank you for your quick response and solution.
I tested the patch and it brings up the CKEditor as expected. Fantastic, this would suffice my use case!
There is actually the same kind of issue for the Confirmation message: a CKEditor field in the form settings, but a plain text field only in the translation form. Would it be possible to change this into a CKEditor field there as well?
If this is too complicated for general implementation - would it be possible to make such changes using a custom module?
Comment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@alexh. In a custom module, you can call the needed form alter hooks and alter the elements has needed.
@see webform/includes/webform.translation.inc
Comment #6
alexh CreditAttribution: alexh commented@jrockowitz thank you for the hint. Your patch made me aware of the 'webform_html_editor' field type. Knowing that, it was quite easy to achieve having a CKEditor in the translation form elements of the confirmation message and email confirmation message, using a custom module.
Just wanted to share my solution on the example of the default Contact form, as it might be useful for someone else:
For other forms, the key 'webform.webform.contact' would need to be adapted.
Comment #7
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedFixing the email handler's body is going to be tricky because it can be Twig, HTML, or a template.
Displaying an HTML Editor for the appropriate webform settings (ie. confirmation_message, error message, etc...) when a webform is translated is much easier.
@see #3204180: When translating a webform settings HTML editor should be displayed
Comment #8
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #9
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedPatch now has test coverage.
Comment #11
jrockowitz CreditAttribution: jrockowitz as a volunteer and at Webform module Open Collective, The Big Blue House commentedPlease consider joining the Webform module's Open Collective to help ensure that the Webform module is maintained.
Comment #12
jrockowitz CreditAttribution: jrockowitz as a volunteer and at Webform module Open Collective, The Big Blue House commented