Internationalization
Built-in locales: zh-CN, en-US.
Basic Usage
<YanivEditor locale="zh-CN" />
<YanivEditor locale="en-US" />
<YanivInlineEditor locale="en-US" v-model:content="html" />normalizeLocaleCode mappings:
zh-TW/zh-HK→zh-CNen→en-US- Other
zh*→zh-CN,en*→en-US
Multi-Instance Isolation
Multiple editors on the same page can use different locale values independently. Demo: /multi-instance.
Where Copy Comes From
Copy inside the editor is read through two paths, and both read built-in locale packs only:
- Tiptap extensions:
ctx.localefrombuildExtensions— a static snapshot frozen when the session is created; - Chrome components:
useEditorT()→inject(editorLocaleKey), reading the per-instance locale.
Do not call the global t() directly inside components or extensions (it breaks multi-instance isolation).
createI18n({ messages }) does not override editor copy
createI18n writes custom messages into the module-level customMessages in locales/manager.ts, and only the global t() looks there. Both editor paths (ctx.locale / provideEditorLocale) come straight from the built-in message object returned by loadLocale() and never consult customMessages. So editor UI copy cannot currently be customized through createI18n.
To change the copy, fork the repo and edit src/locales/zh-CN.ts / en-US.ts.
Locale codes outside normalizeLocaleCode's mappings fall back to zh-CN. Only zh-CN and en-US ship as built-in packs (BUILTIN_LOCALE_CODES); for a missing key, t() falls back to en-US first and then to the key itself.
Known Unlocalized Spots
Editor chrome, media context bars, drag-handle aria-labels, the session skeleton/error copy and the whole AI subpackage UI (settings dialog, provider names and descriptions, connection-test results, the not-configured error, demo-mode streaming copy) all go through the locale.
What remains hard-coded in Chinese is deliberately outside i18n — it is document content or sample data, not interface copy:
| Location | Note |
|---|---|
YanivEditor default initialContent | <p>开始编辑你的文档...</p> — pass your own initial content |
MentionExtension built-in suggestions | "首页 / 文档 / 路线图 / 我" — both the @ menu labels and the label stored on the inserted node; pass real data via mention-items |
System prompts in features/ai/prompts.ts | Chinese prompt templates, but all of them ask for "the same language as the original", so English input still yields English output |
Rule for new AI copy
Modules without a locale context (such as useAiConfig) return locale keys only (e.g. aiSettings.testTimeout); the component holding useEditorT() translates them. client.ts uses the per-instance resolver injected by createConfiguredAiClient. localeParity.test.ts asserts that every AI_PROVIDERS entry has providerName / providerDesc copy in both packs.
locale and session
Changing locale updates sessionKey and triggers session rebuild.