SuperAPI AI Directory

i18n-key-diff

Coding & development

View repository

Updated 10-15 23:45

About this skill

i18n-key-diff — en.json ↔ ja.json key difference detection

en.json と ja.json pairs, and list keys that exist in only one of them. Supports both next-intl (messages/ directory) and content JSON (content/ directory).


Usage

「i18nの差分を確認して」
「翻訳キーが全部揃ってるか確認して」
「en.jsonにあってja.jsonにないキーを教えて」

Execution steps

Step 1: Search for target file pairs

From the project root, list en.json/ja.json pairs with the following command (excluding node_modules):

find . -name "en.json" -not -path "*/node_modules/*" | sort
find . -name "ja.json" -not -path "*/node_modules/*" | sort

Process those where both en.json and ja.json exist in the same directory as a pair.

Step 2: Extract key differences

Obtain the key differences for each pair with the following Python script:

import json, os, sys

def get_flat_keys(obj, prefix=''):
    keys = set()
    if isinstance(obj, dict):
        for k, v in obj.items():
            full = f'{prefix}.{k}' if prefix else k
            if isinstance(v, dict):
                keys |= get_flat_keys(v, full)
            else:
                keys.add(full)
    return keys

def diff_pair(en_path, ja_path):
    with open(en_path) as f:
        en_keys = get_flat_keys(json.load(f))
    with open(ja_path) as f:
        ja_keys = get_flat_keys(json.load(f))
    return en_keys - ja_keys, ja_keys - en_keys

# 使用例
only_en, only_ja = diff_pair('messages/en.json', 'messages/ja.json')

Step 3: Organize and report the results


Output format

## i18n キー差分レポート

### messages/en.json ↔ ja.json
- EN総キー数: 1220 / JA総キー数: 1220
- **ENにあってJAにない(翻訳追加が必要)**: 3件
  - `landing.products.muednote.features.newBadge`
  - `onboarding.step3.title`
  - `auth.errors.tokenExpired`
- **JAにあってENにない(削除済みor余剰)**: 0件

### content/stories/muedear/en.json ↔ ja.json
- EN総キー数: 45 / JA総キー数: 45
- 差分なし ✅

---
**要対応**: 3キー(messages/ja.json への追記が必要)
**問題なし**: 1ペア

Handling guide

When present in EN but not in JA (translation addition required):

  1. Add the corresponding key to the relevant location in ja.json add to the corresponding section of
  2. Use a Japanese translation for the value (a provisional translation is acceptable; refine later)
  3. Confirm again with this skill that the differences become zero

When present in JA but not in EN (surplus key):

  • A key that has already been deleted from EN may remain
  • If it is intentionally kept, it can be ignored
  • If unnecessary, delete from ja.json delete from

Target projects

Main expected use:

  • mued/mued_v2 — messages/en.json + messages/ja.json(next-intl)
  • en/ja JSON pairs under the content directory

It works the same way for other projects if they have en.json/ja.json pairs.


Notes

  • node_modules/ Always exclude the
  • A key whose "value is an empty string" is not detected as a difference (it is OK if the key exists)
  • No limit on nesting depth (because it is flattened for comparison)
  • Keys under JSON array values ([]) are excluded from comparison (because the structure is dynamic)