Agent Skills
› smartdoca/doca
› doca-i18n
doca-i18n
GitHub指导为 Doca 编辑器子包或宿主添加界面语言支持,包括增加 locale prop、维护中英文消息目录及处理字典 key 规范。
Trigger Scenarios
需要为 Doca 编辑器组件添加中文或英文 UI 文案
新增国际化语言支持或修改多语言消息目录
Install
npx skills add smartdoca/doca --skill doca-i18n -g -y
SKILL.md
Frontmatter
{
"name": "doca-i18n",
"description": "Add interface languages to a Doca editor subpackage (rich text, spreadsheet, Markdown, canvas, slides, and future formats) or the Doca host. Use when adding Chinese\/English UI copy, a locale prop, message catalogs, or another language. Dictionary keys are stable English identifiers, not Chinese or full-sentence English."
}
Doca 界面语言
改编辑器子包或 Doca 宿主的界面文案前,先读 界面语言约定。Doca 仓库里的 docs/i18n.md 是源文件;本 skill 的 references/contract.md 是给子包安装的副本。两边要一起改,不能各写各的。
子包自己保存界面文案。不要引用 Doca 的字典,也不要读取 ui.locale 或 localStorage。
子包要做的事
- 给编辑器组件增加可选的
locale?: string。宿主会这样传入:
<RichTextEditor locale={locale} />
当前只有 zh 和 en。不认识的代码按 en 显示。缺省时按 zh 显示。
- 字典 key 用稳定的英文标识,例如
toolbar.bold、find.replaceAll。不要用中文,也不要用会随文案修改的整句英文。 - 至少提供
en和zh两份目录,key 集合相同。新增语言时只加一份目录。 - 占位符写成
{name}。需要区分数量时提供key.one和key.other,调用方传count。 locale变化只更新按钮、菜单、占位符和提示。不要因此重建文档、Y.Doc、协同适配器或插件列表。- 可以额外接受
messages?: Record<string, string>覆盖个别 key。没有这份 prop 也可以。 - 用户写进文档的文字、公式、单元格内容不翻译。
宿主只在安装包的类型声明里已经有 locale 时才传入。类型里还没有这个 prop 时不要先传。
增加一种语言
在宿主 locales 和每个编辑器子包里同时加上同一种语言代码和一份与英文 key 相同的目录。不要改已有 key,也不要改调用方式。
Version History
- 117ce85 Current 2026-10-18 15:23


