Patterns label and description are not translatable

Created on 14 September 2023, about 1 year ago
Updated 1 February 2024, 10 months ago

Problem/Motivation

Pattern (at least the ones declared with YAML)'s label and description, and potentially other properties, are not translatable.

In interface translation, I do not see my patterns description available for translation. I see the pattern label but translating it has no effect.

Proposed resolution

In app/modules/contrib/ui_patterns/src/UiPatternsManager.php::processDefinition(), add:

    // Makes label translatable.
    if ($definition instanceof PatternDefinition) {
      // phpcs:ignore Drupal.Semantics.FunctionT.NotLiteralString
      $label = new TranslatableMarkup($definition->getLabel(), [], ['context' => 'ui_patterns']);
      $definition->setLabel($label);
    }

But this may be not the right place if the problem is only for YAML declared pattern, and all other properties would need to be updated too.

I wonder why there is no YamlDiscovery in the /modules/ui_patterns_library/src/Plugin/UiPatterns/Pattern/LibraryPattern.php plugin. Otherwise I think translatability could be added like in https://git.drupalcode.org/project/ui_styles/-/blob/8.x-1.x/src/StylePlu...

Remaining tasks

Agree on a solution
Implement it

🐛 Bug report
Status

Active

Version

1.0

Component

User interface

Created by

🇫🇷France Grimreaper France 🇫🇷

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024