Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate choice_attr labels for correct matching #18

Merged
merged 1 commit into from
Oct 12, 2023

Conversation

limenet
Copy link
Member

@limenet limenet commented Oct 3, 2023

Say a form has this field:

choices:
  E-Mail: 'email'
  Phone: 'phone'
choice_attr:
  Phone:
    data-icon: 'i-contact'
  E-Mail:
    data-icon: 'i-email'

And the following translation table:

key value
E-Mail E-mail

Then the form is translated as:

choices:
  E-mail: 'email'
  Phone: 'phone'
choice_attr:
  Phone:
    data-icon: 'i-contact'
  E-Mail:
    data-icon: 'i-email'

Which results in this JSON:

"choices":[
  {
    "label":"E-mail",
    "value":"email",
    "data":"email",
    "attr":[
      
    ],
    "labelTranslationParameters":[
      
    ]
  },
  {
    "label":"Phone",
    "value":"phone",
    "data":"phone",
    "attr":{
      "dataIcon":"i-contact"
    },
    "labelTranslationParameters":[
      
    ]
  }
]

This is caused by the non-matching labels in choices (E-mail) and choice_attr (E-Mail) after the partial translation.

Once the "labels" in choice_attr are translated as well, both choices have the attribute set correctly:

"choices":[
  {
    "label":"E-mail",
    "value":"email",
    "data":"email",
    "attr":{
      "dataIcon":"i-email"
    },
    "labelTranslationParameters":[
      
    ]
  },
  {
    "label":"Phone",
    "value":"phone",
    "data":"phone",
    "attr":{
      "dataIcon":"i-contact"
    },
    "labelTranslationParameters":[
      
    ]
  }
]

@limenet limenet added the bug Something isn't working label Oct 3, 2023
@limenet limenet self-assigned this Oct 3, 2023
@limenet limenet requested review from rliebi and pryserv and removed request for rliebi October 3, 2023 05:39
Copy link
Collaborator

@pryserv pryserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks 👍

Functional test also OK

@limenet limenet merged commit 9dfe53f into master Oct 12, 2023
6 checks passed
@limenet limenet deleted the choice-attributes branch October 12, 2023 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants