11 · Element texts of webforms shipped in recipes cannot be translated through locale / localize.drupal.org¶
| Project | Webform |
| Component | Translation |
| Category | Feature request |
| Priority | Normal |
| Status | Draft, not filed on drupal.org yet |
Problem/Motivation¶
A webform stores all its elements as one YAML string (elements, schema type: text). Locale can only translate this string as a whole. Individual texts – titles, placeholders, options, button labels – never reach the translation database, so community or recipe translations cannot be applied.
Drupal CMS site templates ship webforms (Haven, Byte, Convivial Gov, Summit, Provus EDU, Pulse, CareSphere, Convene). On a site installed in German their forms stay English ("Your email address", "Tell us more...", "Send"), although everything else is translated. Webform's own per-element translation only helps if someone creates the translation manually in the UI.
Steps to reproduce¶
- Install Drupal CMS in German with the CareSphere site template.
- Open the contact page: all field labels, placeholders, options and the submit button are English.
Proposed resolution¶
Expose element texts to locale, e.g.
- a config schema per translatable element property (like Webform's own translation manager already knows), so locale can translate #title, #placeholder, #options labels, #submit__label etc. individually, or
- a locale integration that translates element texts from the string database when a webform is created from config.
Remaining tasks¶
Discuss the approach.
Additional information¶
Workaround in dcle (WebformElementsTranslator): translates the element texts one by one and writes the YAML back; option keys are kept.
Copy to drupal.org
Issue title:
Element texts of webforms shipped in recipes cannot be translated through locale / localize.drupal.org
Issue summary (paste it into the "Issue summary" field; project, component, category and priority are in the table above):
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>A webform stores all its elements as one YAML string (<code>elements</code>, schema <code>type: text</code>). Locale can only translate this string as a whole. Individual texts – titles, placeholders, options, button labels – never reach the translation database, so community or recipe translations cannot be applied.</p>
<p>Drupal CMS site templates ship webforms (Haven, Byte, Convivial Gov, Summit, Provus EDU, Pulse, CareSphere, Convene). On a site installed in German their forms stay English ("Your email address", "Tell us more...", "Send"), although everything else is translated. Webform's own per-element translation only helps if someone creates the translation manually in the UI.</p>
<h3 id="summary-steps-reproduce">Steps to reproduce</h3>
<ol>
<li>Install Drupal CMS in German with the CareSphere site template.</li>
<li>Open the contact page: all field labels, placeholders, options and the submit button are English.</li>
</ol>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Expose element texts to locale, e.g.
- a config schema per translatable element property (like Webform's own translation manager already knows), so locale can translate <code>#title</code>, <code>#placeholder</code>, <code>#options</code> labels, <code>#submit__label</code> etc. individually, or
- a locale integration that translates element texts from the string database when a webform is created from config.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>Discuss the approach.</p>
<h3>Additional information</h3>
<p>Workaround in <code>dcle</code> (<code>WebformElementsTranslator</code>): translates the element texts one by one and writes the YAML back; option keys are kept.</p>