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

Comments

DamienMcKenna created an issue. See original summary.

jrockowitz’s picture

Status: Active » Postponed (maintainer needs more info)

Can you please provide some example twig files (in webform/templates)?

damienmckenna’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Never mind, I forgot to enable the Config Translation module.

damienmckenna’s picture

I 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.

damienmckenna’s picture

Title: Field labels, descriptions are not translated » Provide a way of translating field labels and descriptions without changing the form configuration itself
Status: Closed (works as designed) » Active
jrockowitz’s picture

It 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.

damienmckenna’s picture

Issue summary: View changes
jrockowitz’s picture

I think this ticket is becoming a duplicate of the discussion in #2836206: [Translations] Translation of big webforms broken

damienmckenna’s picture

The 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.

jrockowitz’s picture

StatusFileSize
new2.48 KB

I 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.

jrockowitz’s picture

Assigned: Unassigned » jrockowitz

I am now seeing a few possible ways to solve this problem. I just need to get a solid hour free.

  • 75374e2 committed on 3172735-improve-translation-ui
    Issue #3172735 by jrockowitz: Provide a way of translating field labels...

  • 8dbc0d3 committed on 3172735-improve-translation-ui
    Issue #3172735 by jrockowitz: Provide a way of translating field labels...

  • ff7ccb4 committed on 3172735-improve-translation-ui
    Issue #3172735 by jrockowitz: Provide a way of translating field labels...
jrockowitz’s picture

Title: Provide a way of translating field labels and descriptions without changing the form configuration itself » Improve webform elements translation UI and refactor webform translation code
Issue summary: View changes
jrockowitz’s picture

Version: 8.x-5.x-dev » 6.x-dev

  • c59540a committed on 3172735-improve-translation-ui
    Issue #3172735 by jrockowitz: Provide a way of translating field labels...

  • 2a9e12a committed on 3172735-improve-translation-ui
    Issue #3172735 by jrockowitz: Provide a way of translating field labels...

  • 7722134 committed on 3172735-improve-translation-ui
    Issue #3172735 by jrockowitz: Provide a way of translating field labels...

  • ba95914 committed on 3172735-improve-translation-ui
    Issue #3172735 by jrockowitz: Provide a way of translating field labels...

  • f26aece committed on 3172735-improve-translation-ui
    Issue #3172735 by jrockowitz: Provide a way of translating field labels...

  • e2e6c82 committed on 3172735-improve-translation-ui
    Issue #3172735 by jrockowitz: Provide a way of translating field labels...

  • 2e2a02d committed on 3172735-improve-translation-ui
    Issue #3172735 by jrockowitz: Provide a way of translating field labels...

  • 141e709 committed on 3172735-improve-translation-ui
    Issue #3172735 by jrockowitz: Provide a way of translating field labels...

  • 2bb8b16 committed on 3172735-improve-translation-ui
    Issue #3172735 by jrockowitz: Provide a way of translating field labels...

  • b0de850 committed on 3172735-improve-translation-ui
    Issue #3172735 by jrockowitz: Provide a way of translating field labels...

  • 022a746 committed on 3172735-improve-translation-ui
    Issue #3172735 by jrockowitz: Provide a way of translating field labels...
jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new80.56 KB
jrockowitz’s picture

StatusFileSize
new134.1 KB
new94.11 KB

Here is a before and after screenshot.

  • 04a5437 committed on 3172735-improve-translation-ui
    Issue #3172735 by jrockowitz: Provide a way of translating field labels...
damienmckenna’s picture

That's amazing! Thank you Jake!

  • jrockowitz authored 91700d6 on 6.x
    Issue #3172735 by jrockowitz: Improve webform elements translation UI...
jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.