I18n

lobehub/lobehub/.agents/skills/i18n

作者 lobehub6a3eba96b010無授權條款83K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫今天更新

Use for user-facing strings and react-i18next locale keys, namespaces, interpolation, translations or bun run i18n.

AI 產生的概覽

指導在 LobeHub 程式庫中新增與管理 react-i18next 語系鍵與命名空間。

功能
此技能說明 react-i18next 專案中面向使用者字串的慣例:扁平點號鍵、命名空間組織、雙大括號插值,以及避免鍵衝突。它描述將鍵新增至預設語系來源檔案、匯出命名空間,並由每日自動化工作流程產生其他語言的流程。它也介紹元件中的翻譯用法,並列出專案常用命名空間。
適用情境
在為此程式庫新增、編輯或審查面向使用者字串與語系鍵時使用。涉及命名空間、插值或專案翻譯產生流程時也適用。
執行需求
需要 react-i18next 框架與專案的語系檔案結構;手動執行翻譯使用 bun run i18n,並需要 OPENAI_API_KEY。不附帶指令碼,僅為說明文件。

LobeHub Internationalization Guide

  • Default language: English (en-US)
  • Framework: react-i18next
  • Only edit files in packages/locales/src/default/ - Never edit JSON files in locales/ (except hand-written en-US/zh-CN previews)
  • Leave generated locales to the daily auto-i18n.yml workflow by default; run bun run i18n manually only when they are needed immediately

Key Naming Convention

Flat keys with dot notation (not nested objects):

typescript
// ✅ Correctexport default {  'alert.cloud.action': '立即体验',  'sync.actions.sync': '立即同步',  'sync.status.ready': '已连接',};
// ❌ Avoid nested objectsexport default {  alert: { cloud: { action: '...' } },};

Patterns: {feature}.{context}.{action|status}

Parameters: Use {{variableName}} syntax

typescript
'alert.cloud.desc': '我们提供 {{credit}} 额度积分',

Avoid key conflicts:

typescript
// ❌ Conflict'clientDB.solve': '自助解决','clientDB.solve.backup.title': '数据备份',
// ✅ Solution'clientDB.solve.action': '自助解决','clientDB.solve.backup.title': '数据备份',

Workflow

  1. Add keys to packages/locales/src/default/{namespace}.ts
  2. Export new namespace in packages/locales/src/default/index.ts
  3. For dev preview: manually translate locales/zh-CN/{namespace}.json and locales/en-US/{namespace}.json
  4. Leave all other locales to .github/workflows/auto-i18n.yml, which runs daily and opens an automated translation PR
  5. Run bun run i18n manually only when the branch needs those translations immediately; it is slow and requires OPENAI_API_KEY

Usage

tsx
import { useTranslation } from 'react-i18next';
const { t } = useTranslation('common');
t('newFeature.title');t('alert.cloud.desc', { credit: '1000' });
// Multiple namespacesconst { t } = useTranslation(['common', 'chat']);t('common:save');

Common Namespaces

Most used: common (shared UI), chat (chat features), setting (settings)

Others: auth, changelog, components, discover, editor, electron, error, file, hotkey, knowledgeBase, memory, models, plugin, portal, providers, tool, topic

來源與署名

來源:lobehub/lobehub位於.agents/skills/i18n提交6a3eba9

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架