Tools

Language Plugin

Toolbar UI for switching the editor locale. Core locale files live in packages/editor/src/i18n/locales. Large plugins add their own packs under plugins//i18n/locales and merge them on setLocale.

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

LocaleHow it loads
enBundled with the editor (+ each plugin's en.json merged in setup)
othersCore 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).

  • Core — localization API