Make style definition options translatable

Created on 12 December 2024, 3 months ago

hi,
Thank you for this module :)
i use it with Ckeditor to have buttons for text color and background color
these are mainly options from ui_suite_dsfr/ui_suite_dsfr.ui_styles.yml
As guessed, i need to translate the color name :)

I'll attach the patch i use for that need

Feature request
Status

Active

Version

1.12

Component

UI Styles CKEditor 5

Created by

🇫🇷France izus

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

Merge Requests

Comments & Activities

  • Issue created by @izus
  • 🇫🇷France izus

    and here is the patch

  • Status changed to Needs review 27 days ago
  • 🇫🇷France goz

    Looks like this issue has been fixed on 1.1.x. I can see changes of this patch in currnet code.

  • 🇫🇷France goz

    My bad... i don't know how i check this but i was wrong.

    So close duplicate 🐛 Does not cast options label in styles definitions Active and fix this patch

  • 🇫🇷France goz

    Trying to add a card on layout builder with ui_patterns2 and ui_suite_dsfr, i have the following error generating /ui_styles/stylesheet with this patch

    
    InvalidArgumentException: $string ("0") must be a string. in Drupal\Core\StringTranslation\TranslatableMarkup->__construct() (line 132 of core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php).
    
    Drupal\ui_styles\Definition\StyleDefinition->t(0) (Line: 156)
    Drupal\ui_styles\Definition\StyleDefinition->getOptionsAsOptions() (Line: 217)
    Drupal\ui_styles\Service\StylesheetGenerator->getThemeStyleOptions('ui_suite_dsfr') (Line: 68)
    

    ui_suite_dsfr has some style options with int, not string

      options:
        fr-m-0: 0
    

    Proposed resolution

    Cast to string in \Drupal\ui_styles\Definition\StyleDefinition::getOptionsAsOptions()

            $options[$option_id] = $this->t((string) $option);
    
  • Pipeline finished with Failed
    26 days ago
    Total: 348s
    #420765
  • Pipeline finished with Failed
    26 days ago
    Total: 208s
    #420783
  • 🇫🇷France goz

    Tests fail because now options are TranslatableMarkup and not string anymore

Production build 0.71.5 2024