Wrong translation on select #options

Created on 29 November 2023, 7 months ago
Updated 26 February 2024, 4 months ago

Problem/Motivation

The implemented solution for translating select #options with optgroups overwrites the option with the translation_value. When an option doesn't have a translation it will inherit the translation of a previous option.

Steps to reproduce

Using the following config for webform:

example_select:
    '#type': select
    '#title': 'How did you find us?'
    '#options':
      Family/Friends: Family/Friends
      'Google (or other search engine)': 'Google (or other search engine)'
      Indeed: Indeed
      Intermediair: Intermediair
      LinkedIn: LinkedIn
      'Website university': 'Website university'
      Twitter: Twitter
      Facebook/Instagram: Facebook/Instagram
      Reddit: Reddit

And translating this using:

example_select:
    '#options':
      Family/Friends: Familie/Vrienden
      'Google (or other search engine)': 'Google (of andere zoekmachine)'
      'Website university': 'Website universiteit'

The select options are sorted by title in the display. You will see the English select has the following options:

  • Facebook/Instagram
  • Family/Friends
  • Google (or other search engine)
  • Indeed
  • Intermediair
  • LinkedIn
  • Reddit
  • Twitter
  • Website university

Where the dutch version has the following options:

  • Facebook/Instagram
  • Familie/Vrienden
  • Google (of andere zoekmachine)
  • Indeed
  • Intermediair
  • LinkedIn
  • Twitter
  • Website university
  • Website university

As you can see, the last option seems double but is in fact the missing "Reddit" option which inherited it's translation from "Website university".

Proposed resolution

Do not overwrite the option variable when looping through the source_options.

๐Ÿ› Bug report
Status

Fixed

Version

6.2

Component

Code

Created by

๐Ÿ‡ณ๐Ÿ‡ฑNetherlands yaartse

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024