i18n
i18n Skill
Standards and workflow for internationalization. All user-visible text must use i18n.
Announce at start: "I'm using i18n skill to ensure proper internationalization."
IMPORTANT: Read Config First
Before doing any i18n work, always read src/common/config/i18n-config.json to get the current list of supported languages and modules. Never assume a fixed number — languages and modules may have been added or removed since this skill was written.
cat src/common/config/i18n-config.json
This file is the single source of truth. All scripts, runtime code, and this workflow depend on it.
File Structure
src/common/config/i18n-config.json # Single source of truth: languages, modules
src/renderer/i18n/
├── index.ts # i18next configuration
├── i18n-keys.d.ts # AUTO-GENERATED — do not edit manually
└── locales/
├── <lang>/ # One directory per language in i18n-config.json
│ ├── index.ts # Barrel import for all modules
│ ├── common.json # One JSON per module in i18n-config.json
│ ├── conversation.json
│ └── ...
└── ...
Key Facts
- Reference language: defined by
referenceLanguageini18n-config.json(currentlyen-US) - Supported languages: defined by
supportedLanguagesarray — read the file to get the current list - Modules: defined by
modulesarray — read the file to get the current list
Key Structure
Keys use namespaced dot notation in code: t('module.key') or t('module.nested.key').
Inside each module JSON file, keys can be flat or nested:
// common.json — flat keys
{
"send": "Send",
"cancel": "Cancel",
"copySuccess": "Copied"
}
// cron.json — nested keys
{
"scheduledTasks": "Scheduled Tasks",
"status": {
"active": "Active",
"paused": "Paused"
}
}
In code:
t('common.send'); // flat key in common.json
t('cron.status.active'); // nested key in cron.json
Key Naming Rules
- Use camelCase for key names:
copySuccess,scheduledTasks - Group related keys with nesting:
status.active,actions.pause - Reusable text goes in
common.json: save, cancel, delete, confirm, etc. - Feature-specific text goes in the corresponding module
Common Suffixes
| Suffix | Usage |
|---|---|
title |
Section/page titles |
placeholder |
Input placeholders |
label |
Form labels |
success / error |
Status messages |
confirm |
Confirmation dialogs |
empty |
Empty state messages |
tooltip |
Tooltip text |
Adding New Text — Workflow
Step 1: Read src/common/config/i18n-config.json
Get the current language list and module list. Do not skip this step.
Step 2: Check Existing Keys
Before adding a new key, search for similar existing keys:
grep -r "keyword" src/renderer/i18n/locales/en-US/
Reuse common.* keys when possible.
Step 3: Choose the Right Module
Match the module to the feature area. If no module fits, consider whether a new module is needed (see "Adding a New Module" below).
Step 4: Add to ALL Locale Directories
CRITICAL: Every new key must be added to every locale in supportedLanguages. Use this checklist for each key:
-
en-US/<module>.json— reference language (added in Step 3) -
zh-CN/<module>.json— added -
zh-TW/<module>.json— added - Any other language listed in
src/common/config/i18n-config.json→supportedLanguages— added
A key missing from even one locale will cause node scripts/check-i18n.js to fail in CI.
Step 5: Use in Component
import { useTranslation } from 'react-i18next';
function MyComponent() {
const { t } = useTranslation();
return <button>{t('common.save')}</button>;
}
Step 6: Regenerate Types and Validate
Run these two commands in order — both must pass before committing:
bun run i18n:types # Step A: regenerate i18n-keys.d.ts from reference locale
node scripts/check-i18n.js # Step B: validate structure, keys, and type sync
i18n:typesmust be run beforecheck-i18n.js— the check validates the generated file- If
check-i18n.jsexits with errors (❌), fix them before proceeding - If
check-i18n.jsexits with warnings only (⚠️), review but may proceed - Never commit with a stale
i18n-keys.d.ts
Adding a New Module
- Add module name to
src/common/config/i18n-config.json→modulesarray - Create
<module>.jsonin every locale directory (readsupportedLanguagesto know which) - Add import + export in each locale's
index.ts - Run
bun run i18n:typesto regenerate type definitions - Run
node scripts/check-i18n.jsto validate
Hardcoded String Detection
Prohibited Patterns
Never use hardcoded Chinese/English text in JSX:
// Bad
<span>重命名</span>
<span>Delete</span>
{name || '新对话'}
// Good
<span>{t('common.rename')}</span>
<span>{t('common.delete')}</span>
{name || t('conversation.newConversation')}
Exceptions
- Code comments (any language OK)
console.log()/ debug output- Internal string constants not shown to users
Interpolation
Variables
{
"taskCount": "{{count}} task(s)",
"greeting": "Hello, {{name}}!"
}
t('cron.taskCount', { count: 5 });
HTML in Translations
Use Trans component for complex markup:
import { Trans } from 'react-i18next';
<Trans i18nKey='cron.countdown'>
Task <strong>{{ taskName }}</strong> in <span>{{ countdown }}</span>
</Trans>;
zh-TW Maintenance
Most terms can be auto-converted from zh-CN, but some need manual review:
| zh-CN | zh-TW | Notes |
|---|---|---|
| 视频 | 影片 | Different term |
| 软件 | 軟體 | Different term |
| 信息 | 訊息 | Different term |
| 默认 | 預設 | Different term |
Quick Checklist
Before submitting code with new text:
- Read
src/common/config/i18n-config.jsonto get current languages and modules - All user-visible text uses
t()function - New keys added to every locale directory in
supportedLanguages - No hardcoded Chinese/English in JSX
- zh-TW reviewed for term differences
-
bun run i18n:typesran first (regeneratesi18n-keys.d.ts) -
node scripts/check-i18n.jspassed after types regenerated (no errors)
Common Mistakes
| Mistake | Correct |
|---|---|
| Assuming a fixed number of languages | Always read i18n-config.json first |
| Adding key to only some locales | Add to every locale in supportedLanguages |
Editing i18n-keys.d.ts manually |
Run bun run i18n:types to generate |
Using t("New Chat") |
Define key: t("conversation.newChat") |
Not updating i18n-config.json for new module |
Update config first, then create files |
Adding module JSON but not updating index.ts |
Must add import + export in each locale's index.ts |
More from iofficeai/aionui
pptx
Presentation creation, editing, and analysis. When Claude needs to work with presentations (.pptx files) for: (1) Creating new presentations, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other presentation tasks
108docx
Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks
102xiaohongshu-recruiter
用于在小红书上发布高质量的 AI 相关岗位招聘帖子。包含自动生成极客风格的招聘封面图和详情图,并提供自动化发布脚本。当用户需要发布招聘信息、寻找 Agent 设计师或其他 AI 领域人才时使用。
68xlsx
Comprehensive spreadsheet creation, editing, and analysis with support for formulas, formatting, data analysis, and visualization. When Claude needs to work with spreadsheets (.xlsx, .xlsm, .csv, .tsv, etc) for: (1) Creating new spreadsheets with formulas and formatting, (2) Reading or analyzing data, (3) Modify existing spreadsheets while preserving formulas, (4) Data analysis and visualization in spreadsheets, or (5) Recalculating formulas
67openclaw-setup
OpenClaw usage expert: Helps you install, deploy, configure, and use OpenClaw personal AI assistant. Can diagnose issues, create bots, execute automated tasks, etc. Use when users need to install OpenClaw, configure Gateway, set up Channels, create Agents, troubleshoot issues, or perform OpenClaw-related operations.
63skill-creator
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
62