スキル一覧に戻る
Hsiung-Shao

i18n-consistency

by Hsiung-Shao

0🍴 0📅 2026年1月18日
GitHubで見るManusで実行

SKILL.md


name: i18n-consistency description: Ensures translation keys are consistent across all supported locales.

i18n Consistency Skill

Use this skill whenever you modify, add, or delete translation keys in the project. This ensures that zh-TW (Source of Truth) stays in sync with zh-CN, en, ja, and ko.

1. Context & Configuration

  • Source Language: zh-TW
  • Target Languages: zh-CN, en, ja, ko
  • Locales Directory: src/i18n/locales/
  • Structure: Files are separated by namespace (e.g., common.ts, navbar.ts).
  • Key Strategy: The project typically uses flat keys (e.g., 'menu.title': '...') or object structure depending on the file. Check existing patterns in the file.
  • Important: src/i18n/i18n.ts might have keySeparator: false. If so, nested keys won't work standardly; use flat dotted keys if the config demands it, or match the existing file structure exactly.

2. strict Workflow for i18n Changes

Step 1: Analyze

Before editing, list all language files that need to be updated.

  • If you add a key to zh-TW/common.ts, you MUST also update:
    • zh-CN/common.ts
    • en/common.ts
    • ja/common.ts
    • ko/common.ts

Step 2: Implementation (Add/Update)

  1. Edit Source (zh-TW): Add the new key/value.
  2. Translate & Propagate:
    • zh-CN: Convert traditional to simplified.
    • en: Translate to English.
    • ja: Translate to Japanese.
    • ko: Translate to Korean.
  3. Format Check:
    • Ensure the key name is IDENTICAL across all files.
    • Preserve indentation and sorting if possible.

Step 3: Verification (Crucial)

If you have made multiple changes, DO NOT rely on manual checking alone.

  1. Create a temporary script (e.g., scripts/verify-i18n-temp.js) to compare keys.
  2. The script should:
    • Read keys from zh-TW files.
    • Compare against all other locales.
    • Log any missing keys.
  3. Run the script and fix any missing keys immediately.
  4. Delete the script after verification.

3. Reference Script

Use this Node.js logic for verification if needed:

const fs = require('fs');
const path = require('path');

const localesDir = path.join(__dirname, '../src/i18n/locales');
const sourceLang = 'zh-TW';
const targetLangs = ['en', 'zh-CN', 'ja', 'ko'];

// Helper to extract keys (simple regex approach)
function extractKeys(filePath) {
    if (!fs.existsSync(filePath)) return new Set();
    const content = fs.readFileSync(filePath, 'utf-8');
    const keys = new Set();
    // Match 'key': or "key":
    const regex = /^\s*(['"])(.+?)\1\s*:/gm;
    let match;
    while ((match = regex.exec(content)) !== null) {
        keys.add(match[2]);
    }
    return keys;
}

// ... iteration logic to compare sourceKeys vs targetKeys ...

スコア

総合スコア

50/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です