@ betteroffice/docx-i18n (英语)
用户界面字符串、 语言类型和翻译助手
@betteroffice/docx-react 编辑. en 定义
字符串; 其它语言覆盖它们.
安装
bun add @betteroffice/docx-i18n
使用量
把一个地方传给编辑 i18n 道具 :
import { de } from '@betteroffice/docx-i18n';
import { DocxEditor } from '@betteroffice/docx-react';
export function Editor({ file }: { file: File }) {
return <DocxEditor documentBuffer={file} i18n={de} />;
}
通过传播一个地块来覆盖单个字符串. 缺少的密钥或 null 倒计时
英语.
const custom = { ...de, formattingBar: { ...de.formattingBar, bold: 'Fettdruck' } };
语言
en (资料来源), de, (中文(简体) ), fr, (中文(简体) ), he, (中文(简体) ), hi, (中文(简体) ), id, (中文(简体) ), pl, (中文(简体) ), pt-BR, (中文(简体) ), tr 财务报告和审定财务报表 zh-CN编辑
出口额 pt-BR 财务报告和审定财务报表 zh-CN 为: ptBR 财务报告和审定财务报表 zhCN。 。 。 .
每个地方也是自己的地道 比如说 @betteroffice/docx-i18n/pl,所以一个应用程序选择
运行时的地盘只能装入它需要的地盘 . locales 将每个标记映射到它的字符串和
把他们都捆起来.
帮助者
软件包导出类型 LocaleStrings, (中文(简体) ), PartialLocaleStrings, (中文(简体) ), Translations, (中文(简体) ),
TranslationKey, (中文(简体) ), LocaleCode 财务报告和审定财务报表 TFunction函数 createT 财务报告和审定财务报表 deepMerge。 。 。 .
外部反应, 构建输入 t() 直接 :
import { createT, deepMerge, en, de, type LocaleStrings } from '@betteroffice/docx-i18n';
const t = createT(deepMerge(en, de) as LocaleStrings, 'de');
t('formattingBar.bold'); // 'Fett'