Skip to content

#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

Loading