Skip to content
Snippets Groups Projects

#3493070: SDC `enum` props should have translatable labels: use `meta:enum`'

Open #3493070: SDC `enum` props should have translatable labels: use `meta:enum`'
  • If you have an enum without corresponding meta:enum, a deprecation error is thrown:

Defining an enum without the corresponding meta:enum is deprecated in drupal:11.2.0 and will throw an error in drupal:12.0.0. See https://www.drupal.org/node/3519574

  • If you have an enum and a meta:enum, but not all values on enum are defined, a InvalidComponentException is thrown.
  • New getEnumOptions($prop) method in ComponentMetadata returning the enum values => translation
    • Translations use component id + prop name as context as in "Component my-theme-or-module:my-component, my-property prop"
  • From a component twig template, you can do {{ componentMetadata.meta.properties.target[target] }} if you have a prop named target that it's an enum for accessing the translated value. This is NOT recommended, as it ties your component to Drupal, but might be useful.

Closes #3493070

Edited by Christian López Espínola

Merge request reports

Members who can merge are allowed to add commits.
Approval is optional
Code Quality is loading
Test summary results are being parsed
Metrics reports are loading
Merge blocked: 1 check failed

Merge details

  • The source branch is 2 commits behind the target branch.
  • 1 commit will be added to 11.x.
  • Source branch will not be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Wim Leers requested changes

    requested changes

  • added 2 commits

    • 27c62408 - Use provider:machineName for context for avoiding collisions
    • 1cd6f01b - Microoptimization: we can delay the translation until the last moment.

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading