internationalization
它能做什么
这项技能说明如何将面向用户的文本保存在应用的翻译目录中。它涵盖使用哪些语言、如何命名键,以及翻译检查如何运行。适合在支持多种语言的应用中添加或修改文本的开发者。
适用场景
- ✓当你在应用中添加或修改可见文本、标签、提示消息或空状态的时候。
- ✓当应用已选择启用额外语言,需要更新其目录的时候。
- ✓当语言选择器显示了应用实际上无法加载的语言的时候。
技能链接
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/internationalization/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请在设置页面添加一个新标签,并同时更新法语和德语的翻译。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体先将文本添加到英文目录,然后只更新应用列出的语言。它保持相同的键和占位符,并运行 i18n 检查。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Internationalization — opt-in translations
English (en-US) is the default source locale. Do not create or update
additional locale catalogs unless the app's agent-native.config.ts lists them
under translations.locales.
Rule
Visible framework/template UI copy belongs in the app's i18n catalog, not
inline in components. When you add or edit UI text, update the English source
catalog first, then update only the locale catalogs listed in
translations.locales, and run the i18n guard.
Catalogs
Templates use app/i18n/:
en-US.tsis the canonical source tree and fallback.- Other locale files keep the same non-plural keys and the same placeholders.
index.tsexports anAgentNativeI18nCatalogwith English bundled and non-English catalogs loaded by dynamic import.
Use BCP-47 filenames from the supported set: en-US, zh-CN, es-ES,
fr-FR, de-DE, ja-JP, ko-KR, pt-BR, hi-IN, ar-SA.
If an app only ships translations for a subset of that set, set
supportedLocales on the AgentNativeI18nCatalog to that subset. Without it,
<LanguagePicker /> lists every framework-supported locale regardless of
whether loadMessages can actually resolve it.
UI Pattern
- Wrap apps with
AppProviders i18n={{ catalog: i18nCatalog }}. - Read strings with
useT()and keep keys stable. - Apps expose a
/settingsroute without a sidebar item for it: Settings opens from the account menu in the sidebar footer and from ⌘, (Ctrl+, elsewhere). Core's Account › Preferences page already renders the Interface language row (with Timezone; both are the per-userlocalizationrecord, so a change applies in every app); don't add a second picker to an app's Settings page. Keep the header language icon only as a quick-access shortcut. - Don't add an "Agent settings" row to an app's settings page: the Agent
group's pages are part of Settings. Link to a page with
buildSettingsRoute(page, sub?), and localize the link's label. - Settings copy follows the same rules: page and group labels are core
agentChat.settingsShell.*keys, and an app's own rows, areas, and search entries take already translated strings from the app catalog. - Use
useFormatters()for dates, numbers, relative time, and lists instead of embedding formatted values in translation strings. - Do not translate stable identifiers: action names, route names, enum values, app-state keys, database values, protocol fields, env var names, or provider names.
Plurals And Placeholders
Plural strings use i18next/CLDR suffixes. Do not force every locale to copy English plural categories:
- English uses
_oneand_other. - Chinese and Japanese usually use
_other. - Arabic uses
_zero,_one,_two,_few,_many, and_other.
Keep interpolation placeholders identical across locales, such as
{{count}}, {{name}}, or ICU-style {count} arguments.
RTL
New UI should be RTL-safe. Prefer logical CSS utilities/properties such as
ms-*, me-*, ps-*, pe-*, start-*, end-*, text-start, and
text-end when direction matters. Avoid hardcoded left/right positioning for
new localized UI unless it is genuinely physical.
Verification
Run:
pnpm guard:i18n-catalogs
For broader changes, also run the affected template tests and pnpm typecheck.
Machine translation is only a starting point; high-visibility strings need
human review.
常见问题
翻译默认开启吗?
不开启。应用必须在配置中选择启用其他语言。英文是默认语言。
我需要修改每一个语言文件吗?
只需修改应用列为已启用的语言。英文目录总是先更新。
我可以直接把文本写在组件里吗?
技能说明,可见文本应放在目录中,而不是直接写在组件里。
详情
作者的原始描述
How to add or edit localized UI copy in agent-native apps. Use when adding, removing, or changing user-visible interface text, prompts, toasts, labels, empty states, or date/number/list formatting. Apps opt in to additional locales from `agent-native.config.ts`.
repo: BuilderIO/agent-native
热度
- GitHub 星标
- 7.6k
- 排名
- #13165
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …