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>
);
}<script setup lang="ts">
import type { Translations } from '@docx-editor.dev/i18n';
import { DocxEditor, LocaleProvider } from '@docx-editor.dev/vue';
const labels: Translations = {
formattingBar: { bold: 'Bold text', italic: 'Italic text' },
};
</script>
<template>
<LocaleProvider :i18n="labels">
<DocxEditor.Toolbar :preset="false">
<DocxEditor.Toolbar.Bold />
<DocxEditor.Toolbar.Italic />
</DocxEditor.Toolbar>
</LocaleProvider>
</template>Choose the language setting
Interface language, regional formatting, paragraph direction, and shaping language are separate settings.
| Setting | Scope |
|---|---|
LocaleProvider i18n | Catalog for a composed editor or one region. Root has no i18n prop. |
Packaged DocxEditor i18n | Catalog for the packaged editor. |
Root locale | Regional date input and engine-generated labels. Default en-US. |
Root translate | Drawing and form-control label resolver. |
Root tableInteractionLabel | Table insertion and select-handle labels. |
t on toolbar, menus, or review | Region label resolver. |
Font configuration language | Language-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>;
}<script setup lang="ts">
import { useTranslation } from '@docx-editor.dev/vue';
const i18n = useTranslation();
</script>
<template>
<span>{{ i18n.t('formattingBar.bold') }}</span>
</template>Application labels belong in your own catalog. Toolbar.Action label takes resolved text, not a key.
Limits
- Importing the
localesrecord bundles every catalog. To ship only some languages, import each catalog by name. - Missing and
nullvalues inherit from the outer provider. The top-level fallback is English. - Keep the nested key structure and placeholder names in a partial catalog. Set
_langfor language-specific plural rules. - A region
tmust return a real string for every key. Fall back to the active catalog, never the key. - Changing
localeortranslatekeeps the editor instance. Stored date formats stay unchanged. - Interface language does not set paragraph direction. The
arandhecatalogs mirror the interface. See Right-to-left support.