Skip to content

i18n: make RichEditor text color labels translatable#19571

Merged
danharrin merged 7 commits intofilamentphp:4.xfrom
abournavaud:fix/rich-editor-text-color-translations
Apr 3, 2026
Merged

i18n: make RichEditor text color labels translatable#19571
danharrin merged 7 commits intofilamentphp:4.xfrom
abournavaud:fix/rich-editor-text-color-translations

Conversation

@abournavaud
Copy link
Copy Markdown
Contributor

@abournavaud abournavaud commented Mar 26, 2026

Description

Currently, TextColor::getDefaults() uses Str::ucwords($name) to generate color labels (e.g. "Red", "Slate"), which are hardcoded in English. This makes the color dropdown in the RichEditor unusable for non-English locales.

This PR replaces the hardcoded labels with Laravel's __() translation helper, allowing color names to be translated via language files. English and French translations are included. Other locales will fall back to the English translation by default.

  • TextColor::getDefaults() now uses __('filament-forms::components.rich_editor.actions.text_color.modal.form.color.options.{name}') instead of Str::ucwords($name)
  • Added color name translations in lang/en/components.php (26 colors)
  • Added color name translations in lang/fr/components.php (26 colors + full text_color action block)

Visual changes

No visual changes for English users. French users will now see translated color names in the text color dropdown.

Functional changes

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

Use Laravel's translation system for TextColor default labels instead of
hardcoded English names via Str::ucwords(). Add color name translations
for EN and FR locales.
Copy link
Copy Markdown
Member

@danharrin danharrin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the merge conflicts

Please restore the previous behaviour of auto-generating an option label from the color name if the translation is missing from this list. You could fetch the entire list of options first in an array, and then check if the key exists before using the translation.

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Roadmap Mar 27, 2026
@abournavaud abournavaud requested a review from danharrin March 30, 2026 07:43
@danharrin danharrin changed the title feat: make RichEditor text color labels translatable i18n: make RichEditor text color labels translatable Apr 3, 2026
@danharrin danharrin merged commit 7062ee7 into filamentphp:4.x Apr 3, 2026
35 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Roadmap Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants