Skip to content

Localize Redactor editor UI based on Bolt backend locale#41

Open
Vondry wants to merge 4 commits into
bolt:mainfrom
Vondry:main
Open

Localize Redactor editor UI based on Bolt backend locale#41
Vondry wants to merge 4 commits into
bolt:mainfrom
Vondry:main

Conversation

@Vondry

@Vondry Vondry commented Jul 2, 2026

Copy link
Copy Markdown

Summary

This MR makes the Redactor editor UI follow the current Bolt backend locale and normalizes bundled Redactor translation files so plugin and format labels can be localized consistently.

Changes

  • Set Redactor's lang option from the current request locale resolved by Bolt.
  • Auto-load the matching assets/redactor/langs/<code>.js file from redactor_includes().
  • Always load langs/en.js too, so its normalized table overrides the built-in English shipped in redactor.min.js; unsupported locales still fall back to Redactor's built-in English when no file exists.
  • Localize the small format label: switch the formattingAdd entry from a hard-coded 'Small' title to the ## small ## i18n placeholder and add a small key to every bundled langs/<code>.js (previously it read "Small" in every locale, and empty under English).
  • Document the locale behavior in the README.
  • Add missing translation keys across bundled Redactor language files.
  • Update bundled inlinestyle and properties plugins to read more labels through Redactor's language system.

Testing

bolt-cms-redactor-localized.mp4

Vondry added 4 commits July 2, 2026 15:21
The editor language was only settable via a static `lang:` in
`bolt-redactor.yaml`, so on a multi-locale Bolt install every admin saw the
editor in the same hard-coded language regardless of the locale they'd chosen for
the backend. Bolt already resolves a per-user backend locale (LocaleSubscriber
sets the request locale from the user's `_backend_locale`); the editor just never
consulted it.

- RedactorConfig now sets `lang` to the current request locale (RequestStack)
  after the config merge, so the toolbar always follows each user's Bolt locale.
  It is intentionally not overridable — the language is driven solely by the
  user's Bolt admin locale.
- redactor_includes() auto-loads the matching `assets/redactor/langs/<code>.js`
  for the resolved locale, so users no longer add it to `includes` manually.
  English is built in; locales without a shipped translation are skipped and
  Redactor falls back to English on its own.
- Document the behaviour in the README.
The formattingAdd 'small' entry used a hard-coded 'Small' title, so it
showed English in every locale. Switch it to the '## small ##' i18n
placeholder and add a 'small' entry to every langs/<locale>.js.

Also always load langs/en.js (previously skipped for English), so its
normalized table overrides redactor.min.js' built-in 'en' and provides
the new 'small' label.
resolveLocale() set lang to the raw request locale even when no matching
langs/<code>.js is shipped, while redactor_includes() skipped the missing
file. This leaves the config pointing at a language table that was never
loaded, which can leave the toolbar unlocalized or broken.

Resolve the locale against the actually-shipped language file so lang and
the loaded file always agree, falling back to English otherwise.
@Vondry Vondry changed the title Localize Redactor editor UI from Bolt backend locale Localize Redactor editor UI based on Bolt backend locale Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant