{"data":{"slug":"github-lobehub-lobehub-agents-skills-i18n-fc99d3221143","title":"Internationalization with react-i18next","summary":"Manage translations for user-facing strings using react-i18next and the lobe-i18n workflow, with translations generated automatically through the daily `auto-i18n.yml` workflow.","url":"https:\/\/skillshunter.net\/skills\/github-lobehub-lobehub-agents-skills-i18n-fc99d3221143","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-lobehub-lobehub-agents-skills-i18n-fc99d3221143","markdown_url":"https:\/\/skillshunter.net\/skills\/github-lobehub-lobehub-agents-skills-i18n-fc99d3221143.md","download_url":"https:\/\/skillshunter.net\/skills\/github-lobehub-lobehub-agents-skills-i18n-fc99d3221143\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Only edit files in `packages\/locales\/src\/default\/` and avoid hand-writing translations in `locales\/` JSON except for en-US\/zh-CN previews. Generated locales should be left to the daily workflow unless translations are needed immediately, in which case `bun run i18n` must be run manually with an `OPENAI_API_KEY`.","instructions":"---\nname: i18n\ndescription: 'Use for user-facing strings and react-i18next locale keys, namespaces, interpolation, translations or bun run i18n.'\nuser-invocable: false\n---\n\n# LobeHub Internationalization Guide\n\n- Default language: English (en-US)\n- Framework: react-i18next\n- **Only edit files in `packages\/locales\/src\/default\/`** - Never hand-write translations in `locales\/` JSON (except en-US\/zh-CN previews); generated locales change only through `lobe-i18n`, plus the key deletions described in [Changing an existing key's English text](#changing-an-existing-keys-english-text)\n- Leave generated locales to the daily `auto-i18n.yml` workflow by default; run `bun run i18n` manually only when they are needed immediately\n\n## Key Naming Convention\n\n**Flat keys with dot notation** (not nested objects):\n\n```typescript\n\/\/ \u2705 Correct\nexport default {\n  'alert.cloud.action': '\u7acb\u5373\u4f53\u9a8c',\n  'sync.actions.sync': '\u7acb\u5373\u540c\u6b65',\n  'sync.status.ready': '\u5df2\u8fde\u63a5',\n};\n\n\/\/ \u274c Avoid nested objects\nexport default {\n  alert: { cloud: { action: '...' } },\n};\n```\n\n**Patterns:** `{feature}.{context}.{action|status}`\n\n**Parameters:** Use `{{variableName}}` syntax\n\n```typescript\n'alert.cloud.desc': '\u6211\u4eec\u63d0\u4f9b {{credit}} \u989d\u5ea6\u79ef\u5206',\n```\n\n**Avoid key conflicts:**\n\n```typescript\n\/\/ \u274c Conflict\n'clientDB.solve': '\u81ea\u52a9\u89e3\u51b3',\n'clientDB.solve.backup.title': '\u6570\u636e\u5907\u4efd',\n\n\/\/ \u2705 Solution\n'clientDB.solve.action': '\u81ea\u52a9\u89e3\u51b3',\n'clientDB.solve.backup.title': '\u6570\u636e\u5907\u4efd',\n```\n\n## Workflow\n\n1. Add keys to `packages\/locales\/src\/default\/{namespace}.ts`\n2. Export new namespace in `packages\/locales\/src\/default\/index.ts`\n3. For dev preview: manually translate `locales\/zh-CN\/{namespace}.json` and `locales\/en-US\/{namespace}.json`\n4. Leave all other locales to `.github\/workflows\/auto-i18n.yml`, which runs daily and opens an automated translation PR\n5. Run `bun run i18n` manually only when the branch needs those translations immediately; it is slow and requires `OPENAI_API_KEY`\n\n### Changing an existing key's English text\n\n`lobe-i18n` (both the daily workflow and `bun run i18n`) only translates keys that are **missing** from a locale. It never re-translates a key whose English value changed, so editing an existing value leaves every generated locale on the old text indefinitely (e.g. expanded `settingsSearch.tabKeywords.*` stayed stale in 16 locales for weeks).\n\nWhen a change alters an existing key's meaning or content (not just a typo), do one of:\n\n- Rename the key, so it is missing everywhere and gets translated fresh.\n- Re-translate it in the same PR: delete the key from every generated `locales\/*\/{namespace}.json` (all except en-US\/zh-CN), run `bun run i18n`, and commit **only** those keys \u2014 the run also fills unrelated missing keys, which belong to the daily workflow PR.\n- If the stale translation is harmless until the daily run, delete the key from the generated locales so they fall back to English and the workflow re-translates it. Do not do this when the localized text is load-bearing (e.g. search keywords users type in their own language).\n\n## Usage\n\n```tsx\nimport { useTranslation } from 'react-i18next';\n\nconst { t } = useTranslation('common');\n\nt('newFeature.title');\nt('alert.cloud.desc', { credit: '1000' });\n\n\/\/ Multiple namespaces\nconst { t } = useTranslation(['common', 'chat']);\nt('common:save');\n```\n\n## Common Namespaces\n\n**Most used:** `common` (shared UI), `chat` (chat features), `setting` (settings)\n\nOthers: auth, changelog, components, discover, editor, electron, error, file, hotkey, knowledgeBase, memory, models, plugin, portal, providers, tool, topic\n","use_cases":["Translate UI elements for multiple languages","Maintain consistent key naming across locales","Automate translation updates with daily workflows"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/lobehub\/lobehub\/blob\/54382b5c8e81544da454fa6d7b50f461a562c1ee\/.agents\/skills\/i18n\/SKILL.md","source_commit":"54382b5c8e81544da454fa6d7b50f461a562c1ee","license":null,"version":null,"listing_approved_at":"2026-11-22","created_at":"2026-11-21T11:17:07.000000Z","updated_at":"2026-11-22T11:17:05.000000Z","seo_title":"Internationalization with react-i18next","seo_description":"Efficiently manage translations for user-facing strings using react-i18next and the lobe-i18n workflow, with automated translation updates through the daily `auto-i18n` G","seo_keywords":["react-i18next translation","internationalization workflow","locale key management","translation automation"]}}