Webform rendering should use the content language, not interface

Created on 7 October 2020, over 3 years ago
Updated 18 October 2023, 9 months ago

Problem/Motivation

We have a site that uses English as the Interface language, for the editorial team. We are in the process of translating webforms, but it seems the webform renderer uses the INTERFACE language rather than the CONTENT language when rendering it's elements.

IMO this is the wrong approach, a webform feels like it's content rather than part of the interface. I've had the same issue with Block titles and had to make a workaround so that the correct title renders.

However I can imagine this is a breaking change, and a difficult one to judge how much this would effect other sites with existing webforms.

Maybe the better option is to provide a checkbox on the form settings, "Use content language" or something that is opt in.

Steps to reproduce

  1. On a multilingual site, set the interface language detection to "Selected language", set the content language detection to "URL and selected language".
  2. Translate a webform
  3. View the webform in a language other than the interface language, the elements will render in the interface language. (Translation not rendering)
  4. Set the interface language detection to "URL" & "Selected language"
  5. View the webform in a language other than the interface language, the elements will render in the interface language. (Translation rendering)

Proposed resolution

Either:

  • Change Webform rendering to use the content language
  • Add checkbox to allow of content language rendering.

Remaining tasks

Depends on approach.

User interface changes

Depends on approach.

API changes

Depends on approach.

Data model changes

Depends on approach.

📌 Task
Status

Needs review

Version

6.2

Component

Code

Created by

🇳🇿New Zealand DanielVeza Brisbane, AU

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The attached patch adds a new checkbox to both the global configuration and the webform entity settings form under a new group called "Multilingual".
    This adds the ability to force all webforms to be rendered using the content language, or to select specific webforms to be rendered using the content language.
    This is an old issue and I really hope this gets merged soon.

    Webform entity settings

    Global configuration

  • Status changed to Needs work over 1 year ago
  • Updated forms settings and schema for tests to pass.
    Next step is to add a test for this new functionality.

  • 🇩🇪Germany droprocker

    I applied the patch to V6.1.x by removing all the hunks for test files.

    Generally speaking, this patch works like charm! Thanks for the work. :-) I have some improvements, since the functionality can be confusing.

    I think it's not clear enough that the global settings overrides all webform-specific settings. This could be improved. When the global setting is set to content language, the webform-specific setting should be disabled. Otherwise I would expect, that the specific setting overrides the global config.

    Or to have a third option in the webform-specific setting like this (which I prefer):

    • Use global setting - Default
    • Use Interface language
    • Use content language
  • Hi @droprocker,

    Thank you for your feedback.

    The patch follows the general implementation of webform config/settings.

    Referring to

    When the global setting is set to content language, the webform-specific setting should be disabled.

    In fact, this is the case as shown in #20 📌 Webform rendering should use the content language, not interface Needs review , you have the following options:

    • If you have multiple webforms and you need all of them to use the interface language, you can just keep both checkboxes unchecked (global and webform-specific).
    • If you have multiple webforms and you need all of them to use the content language, you will need to check the global checkbox and as a result, the checkbox inside each webform-specific settings will be disabled.
    • If you have multiple webforms and you need only some of them to use the content language instead of the interface language, then you will need to keep the checkbox in the global settings unchecked, and check the checkboxes for the webforms you desire to render in the content language inside the settings of each of them.

    Since the implementation of the current patch covers all use cases, I don't think there is a need for what you suggested lastly:

    Or to have a third option in the webform-specific setting like this (which I prefer):

    • Use global setting - Default
    • Use Interface language
    • Use content language

    Plus, going with such suggestion will create an inconsistency in the UX since other settings work exactly this way (the way that the current patch is implemented).

    On a side note, neither the webform-specific checkbox nor the global checkbox will be available unless the site is multilingual.

  • Added compatibility with 6.2.0-rc2 version.

  • Status changed to Needs review 9 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update 9 months ago
    536 pass
  • 🇩🇪Germany Anybody Porta Westfalica

    @Zulljin could you perhaps prepare this as MR?

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update 8 months ago
    536 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update 8 months ago
    536 pass
  • 🇬🇷Greece gbotis

    Thank you very much! #26 applies perfectly and resolves the issue rendering the form using content language (in my case url).

    I still have issue with confimrations emails. The form values are translated but the subject/body and other fields are still using default language. Has anybody else encountered the same issue?

Production build 0.69.0 2024