Customization

Language and locale

Override DOCX editor interface labels in one region, set regional formatting, and translate your own controls.

Wrap any editor region in LocaleProvider to override its labels. Interface language never translates document text.

Override labels in one region

This nested provider changes two toolbar labels. Menus and the review column work the same way. Other labels inherit.

import type { Translations } from '@docx-editor.dev/i18n';
import { DocxEditor, LocaleProvider } from '@docx-editor.dev/react';

const labels: Translations = {
  formattingBar: { bold: 'Bold text', italic: 'Italic text' },
};

export function ContractToolbar() {
  return (
    <LocaleProvider i18n={labels}>
      <DocxEditor.Toolbar preset={false}>
        <DocxEditor.Toolbar.Bold />
        <DocxEditor.Toolbar.Italic />
      </DocxEditor.Toolbar>
    </LocaleProvider>
  );
}

Choose the language setting

Interface language, regional formatting, paragraph direction, and shaping language are separate settings.

SettingScope
LocaleProvider i18nCatalog for a composed editor or one region. Root has no i18n prop.
Packaged DocxEditor i18nCatalog for the packaged editor.
Root localeRegional date input and engine-generated labels. Default en-US.
Root translateDrawing and form-control label resolver.
Root tableInteractionLabelTable insertion and select-handle labels.
t on toolbar, menus, or reviewRegion label resolver.
Font configuration languageLanguage-sensitive shaping.

For catalog imports and the locale list, see @docx-editor.dev/i18n.

Translate custom controls

useTranslation() returns t, catalogue, and lang. Pass t a typed TranslationKey and named placeholder values. Format numbers with lang.

import { useTranslation } from '@docx-editor.dev/react';

export function BoldHint() {
  const { t } = useTranslation();
  return <span>{t('formattingBar.bold')}</span>;
}

Application labels belong in your own catalog. Toolbar.Action label takes resolved text, not a key.

Limits

  • Importing the locales record bundles every catalog. To ship only some languages, import each catalog by name.
  • Missing and null values inherit from the outer provider. The top-level fallback is English.
  • Keep the nested key structure and placeholder names in a partial catalog. Set _lang for language-specific plural rules.
  • A region t must return a real string for every key. Fall back to the active catalog, never the key.
  • Changing locale or translate keeps the editor instance. Stored date formats stay unchanged.
  • Interface language does not set paragraph direction. The ar and he catalogs mirror the interface. See Right-to-left support.

See also