@eigenpal/docx-editor-i18n (英语)
共享区域字符串、类型和运行时间助手 docx 编辑器 适应器. 翻译的真相来源 @eigenpal/docx-editor-react 财务报告和审定财务报表 @eigenpal/docx-editor-vue。 。 。 .
快速启动
npm install @eigenpal/docx-editor-i18n
将一个打入的语境传递给编辑器 i18n 道具 :
// React
import { de } from '@eigenpal/docx-editor-i18n';
<DocxEditor documentBuffer={file} i18n={de} />
// Vue
import { de } from '@eigenpal/docx-editor-i18n';
<DocxEditor :document-buffer="file" :i18n="de" />
将社区语言与自定义覆盖相混合 :
import { de } from '@eigenpal/docx-editor-i18n';
const myLocale = {
...de,
toolbar: { ...de.toolbar, bold: 'Fettdruck' },
};
密钥设置到 null 在任何一个地方, 回到英语.
软件包
| 软件包 | 说明 |
|---|---|
@eigenpal/docx-editor-react | |
@eigenpal/docx-editor-vue | |
@eigenpal/docx-editor-core | 框架-不可知核:OOXML 解析器,序列器,布局引擎,ProseMirror schema. 取决于此, 如果您要叉出反应或 Vue 适配器 . |
@eigenpal/docx-editor-i18n | 两个适配器消耗的共享地块串和类型. |
@eigenpal/docx-editor-agents | 代理SDK和聊天UI:框架-不可知桥,MCP服务器,AI SDK适配器,外加React UI. |
伪造适配器? 取出叉子细. 取决于
@eigenpal/docx-editor-core直接如此解析器,序列器, 和渲染自动修复您的建筑中的地块, 不回转每个上游变化的手.
可用地点
| 代码 | 导出 | 语言 |
|---|---|---|
en | en | 英语( 来源) |
de | de | 德语 |
he | he | 希伯来语Name |
pl | pl | 波兰语Name |
pt-BR | ptBR | 葡萄牙语( 巴西) |
tr | tr | 土耳其语Name |
zh-CN | zhCN | 简化中文 |
BCP-47 代码(pt-BR, (中文(简体) ), zh-CN(a) 使用骆驼Case JS标识符(ptBR, (中文(简体) ), zhCN) (中文(简体) ). 以标签搜索运行时间 :
import { locales } from '@eigenpal/docx-editor-i18n';
<DocxEditor i18n={locales[userPreferredLocale]} />
导入
locales把每个地方都拉入你的包里 对于更小的捆绑,只进口需要的名字;sideEffects: false让剩下的树摇倒地.
每个地方的子路径
对于在跑步时间选择地产的应用,上面命名的出口不会被树震——捆绑者无法知道哪个地产胜出,所以将其全部运走. 使用每个本地的子路径代替 。 每个都将一个单一的地块(~30KB)和代码分割干净地捆绑:
// Static — bundler ships only this locale's strings
import pl from '@eigenpal/docx-editor-i18n/pl';
// Dynamic — splits into its own chunk, loaded on demand
const pl = (await import('@eigenpal/docx-editor-i18n/pl')).default;
每个地方的子路径船: /en, (中文(简体) ), /de, (中文(简体) ), /he, (中文(简体) ), /pl, (中文(简体) ), /pt-BR, (中文(简体) ), /tr, (中文(简体) ), /zh-CN。每个单位还出口其用地作为命名的约束(import { pl } from '@eigenpal/docx-editor-i18n/pl'),用于选择非违约进口的呼叫者.
类型
import type {
LocaleStrings, // shape of `en`, the full source of truth
PartialLocaleStrings, // shape of a community partial (null falls back)
Translations, // alias for PartialLocaleStrings
TranslationKey, // 'toolbar.bold' | 'dialogs.findReplace.title' | ...
LocaleCode, // 'en' | 'de' | 'pt-BR' | ...
TFunction, // signature of the `t()` callback
} from '@eigenpal/docx-editor-i18n';
非反应/ 虚拟主机
构建已键入 t() 适配器包外 :
import { createT, deepMerge, en, de, type LocaleStrings } from '@eigenpal/docx-editor-i18n';
const merged = deepMerge(en, de) as LocaleStrings;
const t = createT(merged, 'de');
t('toolbar.bold'); // 'Fett'
t('dialogs.findReplace.matchCount', { current: 3, total: 15 }); // ICU plurals
en.json 是真理的来源。 在此添加密钥, 然后运行 bun run i18n:fix 从 repo 根到同步社区地块( 新密钥土地为 null) (中文(简体) ). 全向导 : 文件/i18n.md。 。 。 .
捐款
欢迎捐款。 见 捐款额 用于设置,测试,以及一次性CLA签名.
商业支助
[TIP] 问题还是习惯特征? 电子邮件 docx-编辑器@eigenpal.com。 。 。 .