- 文案放在
locales/<lang>.json;en.json必需,官方插件要求en与zh齐全。 ctx.t(key, options)(命令里)与panel.t(key, options)(面板里)是同一个实现:- key 用点分隔取嵌套值:
t('errors.notFound'); {{name}}插值(不转义:面板用 React 渲染会自己转义;用 innerHTML 时请自己转义);- 带
count时取复数形式key_one/key_other(按 Intl.PluralRules;中文只有_other); - 当前语言找不到的 key 退回英文,英文也没有就返回 key 本身。
- key 用点分隔取嵌套值:
- 插件名(
nameKey)≤ 40 字;每个命令的title必须在en.json里有文案(build 时检查)。 - 给模型看的
description与参数说明一律英文(模型对英文工具说明最稳定),给人看的一律走文案文件。 - 日期时间用
toLocaleString(ctx.locale / panel.locale)格式化;不要把 "Oct 3" 这类格式写死在文案里。
Browse the docs
The developer docs are currently available in Chinese only. The SDK, the CLI and every code sample work the same in any language.
国际化
文案文件、插值、复数