Language Plugin
Usage
import { Editor, LanguagePlugin } from 'on-codemerge';
const editor = new Editor(container, {
plugins: [LanguagePlugin()],
});
await editor.setLocale('ru');
await editor.setLocale('en'); // same API
editor.t('common.cancel');
Demo
How loading works
| Locale | How it loads |
|---|---|
en | Bundled with the editor (+ each plugin's en.json merged in setup) |
| others | Core pack via import.meta.glob, then plugin overlays awaited by setLocale |
editor.setLocale(code) is always Promise<void>: it loads the core pack if needed, awaits plugin overlays, then switches. registerLocale(locale, dict) merges without blocking the core load. LanguagePlugin only opens the language menu and remembers the choice in localStorage.
editor.listLocales(); // ['de','en','es',…]
await editor.setLocale('ja');
editor.registerLocale('xx', { toolbar: { bold: 'Bld' } }); // merge overlay / custom pack
Key parity across locale packs: pnpm run check:locales (editor + each plugins/*/i18n/locales).
Related
- Core — localization API
Responsive
The Responsive Plugin provides responsive design and preview capabilities for the on-CodeMerge editor, allowing users to test and preview content at different screen sizes and breakpoints.
Spell Checker
Live spell check via the in-house Hunspell engine (@codemerge/hunspell, also bundled into on-codemerge). Dictionaries are not shipped with on-codemerge — you pass .aff / .dic URLs when creating the plugin.