@docx-editor.dev/i18n

Locale catalogs for editor controls, including right-to-left Arabic and Hebrew.

Set the interface language

Install the package as a direct dependency when you import its catalogs:

npm install @docx-editor.dev/i18n

Pass a catalog to i18n. This example uses Spanish controls and Spanish regional date input:

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

<DocxEditor document={bytes} i18n={es} locale="es-ES" />;
PropSetsDefault
i18nInterface stringsThe enclosing LocaleProvider catalog, or English
localeRegional date input and generated labelsen-US

Neither setting infers the other. For date input, see form fields.

Choose a catalog

CodeLanguageNamed exportDirection
enEnglishenLTR
arArabicarRTL
plPolishplLTR
deGermandeLTR
esSpanishesLTR
frFrenchfrLTR
pt-BRBrazilian PortugueseptBRLTR
heHebrewheRTL
hiHindihiLTR
idIndonesianidLTR
jaJapanesejaLTR
ruRussianruLTR
trTurkishtrLTR
zh-CNChinese (Simplified)zhCNLTR
  • Hyphenated codes use camelCase exports: ptBR and zhCN.
  • A named import (import { es } from '@docx-editor.dev/i18n') suits a fixed set of locales.
  • A dynamic subpath import loads a locale on demand: (await import('@docx-editor.dev/i18n/es')).default. A static subpath import bundles it.

Configure providers and imports

APIUse
i18n prop on <DocxEditor>Sets the catalog for one packaged editor.
LocaleProviderShares a catalog across editors. Composed editors need it, because DocxEditor.Root has no i18n prop.
dir="rtl" on LocaleProviderMirrors the controls for a catalog without _dir.
useTranslation()Returns t so custom controls read the same catalog.

This example shares a catalog and reads it in a custom control:

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

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

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

For composed editors, see the React and Vue examples. For scoped overrides, see Language.

Limits

  • Each catalog overrides the inherited catalog one key at a time.
  • Missing and null keys inherit from an outer provider. Without one, they fall back to English.
  • Arabic and Hebrew catalogs declare _dir: 'rtl', and the controls mirror. Set _dir: 'rtl' in your own catalog, or pass dir="rtl". See Right-to-left support.
  • Korean document text does not need a Korean interface catalog. See CJK text.

Next steps