#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 namedtarget
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
Activity
added 1 commit
- 9fd8b533 - Trigger deprecation message if no meta:enum is present corresponding an enum
added 4 commits
- 7d6a2d1c - Validate that enum and meta:enum keys match.
- e7b6e5a5 - We care that the enum and meta:enum keys match, but we shouldn't be strict about the order.
- 414b22aa - Added meta:enum to some core components.
- 94fad9fb - Throw exception if meta:enum is not defined to detect all the components we...
Toggle commit list- Resolved by Wim Leers
- Resolved by Christian López Espínola
- Resolved by Christian López Espínola
- Resolved by Christian López Espínola
- Resolved by Christian López Espínola
- Resolved by Christian López Espínola
- Resolved by Christian López Espínola
- Resolved by Christian López Espínola
- Resolved by Christian López Espínola
Please register or sign in to reply