@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. The React adapter consumes it through the i18n prop.
npm install @docx-editor.dev/i18nYou usually don't install this directly. -react pulls it in transitively. Install it explicitly only when you're using the locale data outside the editor (a custom toolbar, a search dropdown, that kind of thing).
Available locales
| Code | Language | Named export |
|---|---|---|
en | English | en |
pl | Polish | pl |
de | German | de |
fr | French | fr |
pt-BR | Brazilian Portuguese | ptBR |
he | Hebrew | he |
hi | Hindi | hi |
id | Indonesian | id |
tr | Turkish | tr |
zh-CN | Chinese (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 locale object to the i18n prop. React:
import { DocxEditor, LocaleProvider } from '@docx-editor.dev/react';
import { pl } from '@docx-editor.dev/i18n';
<LocaleProvider i18n={pl}>
<DocxEditor document={bytes} />
</LocaleProvider>;LocaleProvider merges your catalog over English, so a locale that has not translated every key falls back per key rather than per language. It localizes the packaged editor and any chrome parts you compose yourself (DocxEditor.Toolbar, DocxEditor.Menu, …) alike. Chrome you write from scratch reads the same catalog through useTranslation():
import { useTranslation } from '@docx-editor.dev/react';
const { t } = useTranslation();
<button>{t('toolbar.bold')}</button>;Next steps
- Contributing a translation: add or improve a locale with one JSON file
- i18n API reference
- React API reference
Architecture
How the editor renders DOCX with Word fidelity: one canonical OOXML tree, a DOM-free layout pass, and painted pages that are themselves the editable surface.
Contributing a translation
Add a new editor language to @docx-editor.dev/i18n: scaffold the locale JSON, fill the strings, validate, and open a PR. Partial translations welcome.