Problem/Motivation
Field labels and translations should be translatable without needing to change the form configuration. The majority of site users want to translate the labels per language, not change the form's YAML configuration itself.
Proposed resolution
TBD.
Remaining tasks
- Work out how to make this work.
- Build a patch.
- Eat some of that tasty Drupal 9 cake.
User interface changes
Individual elements and properties (ie label, description, error message, etc...) will be translatable.
API changes
- Add new WebformTranslationConfigManager service
- Add new WebformTranslationLingotekManager service
Data model changes
n/a
Steps to review
Enable webform_test_translation.module
Confirm webform translations are working as expected
- /admin/structure/webform/manage/contact/translate/es/edit
Confirm webform options translations are working as expected
- /admin/structure/webform/config/options/manage/days/edit/translate/es/add
Confirm webform image select translations are working as expected
- /admin/structure/webform/config/images/manage/animals/edit/translate/es/add
Confirm webform custom options translations are working as expected
- /admin/structure/webform/config/options_custom/manage/buttons/edit/translate/es/add
Confirm webform node/field translations are working as expected
- /admin/structure/types/manage/webform/translate/es/add
- /admin/structure/types/manage/webform/fields/node.webform.webform/translate
Confirm webform block translations are working as expected
- /admin/structure/block/add/webform_block/bartik?region=sidebar_second
- /admin/structure/block/manage/webform/translate/es/add
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | webform-translation-after.png | 94.11 KB | jrockowitz |
| #29 | webform-translation-before.png | 134.1 KB | jrockowitz |
| #28 | 3172735-28.patch | 80.56 KB | jrockowitz |
| #10 | 3172735-10.patch | 2.48 KB | jrockowitz |
Comments
Comment #2
jrockowitz commentedCan you please provide some example twig files (in webform/templates)?
Comment #3
damienmckennaNever mind, I forgot to enable the Config Translation module.
Comment #4
damienmckennaI wonder, though, could the field labels and descriptions be translated during field rendering, rather than going through the configuration translation system? Our site users don't want to change the configuration per language, they just want to change "first name" into "nombre de pila" without screwing up a complex YAML structure.
Comment #5
damienmckennaComment #6
jrockowitz commentedIt is not possible for Drupal's interface translation systems to find translatable strings in configuration file.
Right now, YAML is the only way to translate webform labels and descriptions.
Comment #7
damienmckennaComment #8
jrockowitz commentedI think this ticket is becoming a duplicate of the discussion in #2836206: [Translations] Translation of big webforms broken
Comment #9
damienmckennaThe other issue was focused around resolving the ability to translate the entire configuration object, whereas this is a focused look at just translating the user-visible strings.
Comment #10
jrockowitz commentedI think there might be a way to add support for a element definition to a webform element's translatable properties. This would make it possible to replace the element's YAML editor with textfields, textareas, and even the HTML Editor.
Attached is an initial API only POC.
Comment #11
jrockowitz commentedI am now seeing a few possible ways to solve this problem. I just need to get a solid hour free.
Comment #15
jrockowitz commentedComment #16
jrockowitz commentedComment #28
jrockowitz commentedComment #29
jrockowitz commentedHere is a before and after screenshot.
Comment #31
damienmckennaThat's amazing! Thank you Jake!
Comment #33
jrockowitz commented