Skip to content

Localize the Article editor UI based on Bolt backend locale#49

Open
Vondry wants to merge 4 commits into
bolt:mainfrom
Vondry:feature/reactive-editor-locale
Open

Localize the Article editor UI based on Bolt backend locale#49
Vondry wants to merge 4 commits into
bolt:mainfrom
Vondry:feature/reactive-editor-locale

Conversation

@Vondry

@Vondry Vondry commented Jul 3, 2026

Copy link
Copy Markdown

Localize the Article editor UI

Adds full localization to the Article rich-text editor. Previously the editor shipped no language files and was English-only, with no way to follow the per-user Bolt backend locale that Bolt already resolves.

What changed

  • Locale-driven editor UIArticleConfig sets editor.lang to the current request locale after the config merge, so the toolbar and popups always follow each user's Bolt admin locale (via LocaleSubscriber / _backend_locale). This is intentionally not overridable.
  • Auto-loaded language filesarticle_includes() loads the matching assets/article/langs/<code>.js before the plugin scripts, so each plugin's own translations.en deep-merges on top and the English fallback stays complete for every enabled plugin.
  • Safe fallback — the locale is resolved against the actually-shipped language file, so editor.lang and the loaded file always agree. Unknown or unshipped locales fall back to the built-in English instead of rendering an empty toolbar.
  • Shipped locales — English (en.js, the canonical editable set) plus Czech, German, Spanish, French, Croatian, Italian, Dutch, Polish, Russian, Slovak, and Slovenian.

Adding a language

Copy langs/en.jslangs/<code>.js and translate. Missing keys fall back to English automatically.

Also

  • Updated the plugin options list in config.yaml.
  • Documented the localization behaviour in the README.

Testing

bolt-cms-article-localized.mp4

Vondry added 4 commits July 2, 2026 18:50
The Article editor had no localization: it shipped no language files and its UI
was English-only, with no way to follow the per-user Bolt backend locale that Bolt
already resolves (LocaleSubscriber sets the request locale from the user's
`_backend_locale`).

- ArticleConfig sets `editor.lang` to the current request locale after the config
  merge, so the toolbar/popups always follow each user's Bolt locale. It is
  intentionally not overridable — driven solely by the user's Bolt admin locale.
- article_includes() auto-loads the matching `assets/article/langs/<code>.js`,
  emitted BEFORE the plugin scripts so each plugin's own `translations.en`
  deep-merges on top and the English fallback stays complete for every enabled
  plugin. Locales without a file fall back to the built-in English.
- Ship `langs/en.js` (the canonical, editable English set) and `langs/cs.js`
  (Czech). Adding a language is copy en.js -> <code>.js and translate; missing
  keys fall back to English.
- Document the behaviour in the README.
resolveLocale() set editor.lang to the raw request locale even when no
matching langs/<code>.js is shipped, while article_includes() skipped the
missing file. The editor does not fall back on its own: an unknown lang
table resolves every toolbar label to undefined, rendering an empty UI.

Resolve the locale against the actually-shipped language file so editor.lang
and the loaded file always agree, falling back to English otherwise.
@Vondry Vondry changed the title Localize the Article editor UI Localize the Article 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