Localize the Article editor UI based on Bolt backend locale#49
Open
Vondry wants to merge 4 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ArticleConfigsetseditor.langto the current request locale after the config merge, so the toolbar and popups always follow each user's Bolt admin locale (viaLocaleSubscriber/_backend_locale). This is intentionally not overridable.article_includes()loads the matchingassets/article/langs/<code>.jsbefore the plugin scripts, so each plugin's owntranslations.endeep-merges on top and the English fallback stays complete for every enabled plugin.editor.langand the loaded file always agree. Unknown or unshipped locales fall back to the built-in English instead of rendering an empty toolbar.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.js→langs/<code>.jsand translate. Missing keys fall back to English automatically.Also
config.yaml.Testing
bolt-cms-article-localized.mp4