i18n

@docx-editor.dev/i18n

Locale data for the editor chrome. Ships ten languages: English, Polish, German, French, Portuguese, Hebrew, Hindi, Indonesian, Turkish, and Chinese.

Locale data for the editor UI. Both adapters consume it through the i18n prop.

npm install @docx-editor.dev/i18n

Add this package as a direct dependency when importing its catalogs, including for the editor's i18n prop.

UI language and date input

i18n supplies UI translations; locale selects regional date input and generated document labels. Neither setting infers the other. UI strings default to English or an inherited catalog; locale defaults to en-US.

import { DocxEditor } from '@docx-editor.dev/react';
import { pl } from '@docx-editor.dev/i18n';

// English UI, Polish dates (with no inherited catalog)
<DocxEditor document={bytes} locale="pl-PL" />;

// Polish UI, Polish dates
<DocxEditor document={bytes} locale="pl-PL" i18n={pl} />;

In Vue, use locale="pl-PL" and :i18n="pl" on <DocxEditor>. For composed editors, wrap Root and its chrome in LocaleProvider; Root has no i18n prop. See the React and Vue examples. See form fields for supported date input.

Available locales

CodeLanguageNamed export
enEnglishen
plPolishpl
deGermande
frFrenchfr
pt-BRBrazilian PortugueseptBR
heHebrewhe
hiHindihi
idIndonesianid
trTurkishtr
zh-CNChinese (Simplified)zhCN

Two import shapes are supported:

  • Named exports off the root (import { pl } from '@docx-editor.dev/i18n'). Use this when you ship a small static list of locales. Hyphenated codes (pt-BR, zh-CN) become camelCase exports (ptBR, zhCN).
  • Per-locale subpath imports (import pl from '@docx-editor.dev/i18n/pl'). Use this when you dynamically load locales; the per-locale subpath code-splits so users only download the language they need.

Verify what your installed version ships:

ls node_modules/@docx-editor.dev/i18n/

Wiring into the editor

Pass the catalog to i18n. These examples change UI language only; date input keeps the default en-US conventions.

import { DocxEditor } from '@docx-editor.dev/react';
import { pl } from '@docx-editor.dev/i18n';

<DocxEditor document={bytes} i18n={pl} />;

For several editors, or for chrome parts you compose yourself, put the catalog in context once instead:

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

<LocaleProvider i18n={pl}>
  <DocxEditor.Toolbar />
  <DocxEditor document={bytes} />
</LocaleProvider>;

In both cases, the catalog merges over English, so a locale that has not translated every key falls back per key rather than per language. Providers nest: an inner one, or an i18n prop under an outer provider, overrides only the keys it names. Chrome you write from scratch reads the same catalog through useTranslation():

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

const { t } = useTranslation();
<button>{t('formattingBar.bold')}</button>;

Next steps

On this page