i18n String Migration Skill
SkillAI & modelsGuide for coding agents to migrate user-visible strings to the @spherse/i18n package and update locale catalogs
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the i18n String Migration Skill skill
What this skill tells your AI
The instructions your AI receives, as published by mengrru/spherse in .agents/skills/i18n/SKILL.md and read by ahel’s review.
Purpose
This skill guides the coding agent through identifying user-visible strings in Spherse source code, adding them to the shared @spherse/i18n locale catalogs, and replacing hardcoded text with t() calls.
Scope
What to translate
- React component text shown to users (buttons, labels, placeholders, error messages, empty states, dialog titles)
- Electron IPC error/confirmation messages shown to users
- Web shell UI (version guard, connect page)
What NOT to translate
- Anything in
packages/serverorpackages/core— they do NOT depend on@spherse/i18n. Server/core surface errors as structured codes (e.g. chatErrorEventCode); the renderer owns the i18n rendering decision - Route paths, query parameters, storage keys
- CSS class names, ARIA ids, test ids
- API endpoint paths
- Provider/model names and env key identifiers
- Console debug/log messages (unless also shown to users)
- Test data and test assertions
- File paths and technical identifiers
- Markdown content within project files (user content)
Key Naming Convention
Use dot-path namespacing: {domain}.{section}.{specific}
Examples:
app.loadingsettings.titlesettings.models.defaultModelcontent.save.errorchat.error.modelNotConfiguredproject.open.failed
Step-by-step Process
-
Scan the specified files or directories for user-visible string literals.
-
Classify each string: is it user-visible UI text or a technical string that should not be translated?
-
Generate keys for user-visible strings using the naming convention above. Keep keys stable and descriptive.
-
Add entries to all three locale files in
packages/i18n/src/locales/:zh-CN.ts— the canonical catalog (add asas const)zh-TW.ts— Traditional Chinese translationen.ts— English translation
-
Replace the hardcoded string in source code:
- In React components:
const { t } = useI18n();thent("key") - In Electron main / web shell:
translate(locale, "key", params)(using locale from settings or provider)
- In React components:
-
For strings with variables: use
{name}interpolation in the locale value, never concatenate translated parts:- ✅
"无法读取文件:{path}"+t("key", { path }) - ❌
"无法读取文件:" + path
- ✅
-
Run validation:
npm run check:i18nFix any key consistency or interpolation variable mismatches.
-
Run build and tests:
npm run build npm test -w @spherse/i18n -
Report: list all new/modified keys and any strings intentionally left untranslated with reasons.
Catalog Location
- Locale files:
packages/i18n/src/locales/{zh-CN,zh-TW,en}.ts - Canonical catalog &
TranslationKeyderivation:packages/i18n/src/catalog.ts - Translation API:
packages/i18n/src/translate.ts
Important Rules
zh-CN.tsis the canonical source of truth for keys. All other locales must have identical key sets.- Never edit
TranslationKeytype manually — it is derived fromzhCNobject keys. - After adding keys, always run
npm run check:i18nto verify consistency. - Prefer semantic keys (
settings.title) over structural keys (dialog.header.text).
Signals
- GitHub stars
- 73
- Forks
- 8
- Last commit
- Sep 2026
- Hacker News mentions
- 4
Advanced
- Catalog kind
- skill
- Gateway key
i18n-mengrru- Source
- github.com/mengrru/spherse