i18n バリデーター
翻訳ファイルのキー不足、壊れたプレースホルダー、複数形の不整合をリントします。1 つのコマンド、9 種類のチェック、32 形式、設定不要です。
課題
翻訳の問題は、ユーザーが遭遇するまで表面化しません。キーが不足していると、実際のテキストではなく "settings.billing.title" のような未処理のパスが表示されます。プレースホルダーが壊れていると、"$9.99" の代わりに "{price}" がそのまま表示されます。複数形の定義が不正だと、件数が 0 のときにクラッシュします。15 個のロケールファイルを手作業で差分確認する人はいないため、こうしたバグはコードレビューをすり抜けます。
Missing keys
Blank text or key paths shown to users
Broken placeholders
{price} displays as literal text instead of $9.99
Orphaned files
Outdated translations confuse the build system
Malformed files
Runtime crashes when users switch languages
解決策
i18n-validate は、すべての翻訳ファイルを 1 回でスキャンします。ディレクトリ構成とファイル形式を自動検出し、各言語を参照言語と比較して、問題の内容と場所を正確に報告します。プラグイン、設定、独自のテストコードは必要ありません。
| Check | Severity | What it catches |
|---|---|---|
| missing-keys | error | Key exists in reference but is absent in a translation |
| extra-keys | error | Key exists in translation but not in the reference |
| placeholders | error | {price}, {{name}}, %s differ between languages |
| plural-structure | error | Plural forms are malformed or missing required categories |
| missing-languages | error | Expected language has no files or directory |
| orphaned-languages | error | Language files exist but are not in the expected list |
| parse-errors | error | File fails to parse (broken JSON, XML, YAML, etc.) |
| empty-values | warning | Key is present but the translation is an empty string |
| untranslated | warning | Translation is identical to the reference language |
i18n-validate v0.1.0 — validating ./locales
Reference: en (2 files: translation.json, apiTester.json)
Languages: de, ja, fr, es, zh-Hans, pt-BR, ko (7 found, 7 expected)
Layout : directory (auto-detected)
Formats : i18next JSON (auto-detected)
────────────────────────────────────────────────
ERRORS (5)
✗ missing-keys │ translation.json
Key "settings.billing.title"
missing in: ja, ko
✗ placeholders │ translation.json
Key "pricing.total" — expected: {price}, {currency}
de: found {price} only — missing {currency}
────────────────────────────────────────────────
WARNINGS (2)
⚠ empty-values │ translation.json
Key "onboarding.step3.hint"
empty in: de, fr
────────────────────────────────────────────────
5 errors, 2 warnings across 7 languages
✗ Validation failedインストール
お好みのパッケージマネージャーを使用して、グローバル CLI ツールとしてインストールします。npm パッケージにはネイティブの Rust バイナリが同梱されているため、コンパイルもランタイム依存関係も必要ありません。
npm install -g @i18n-agent/i18n-validate使用方法
ツールにロケールディレクトリを指定します。参照言語、ディレクトリ構成、ファイル形式が自動的に検出されます。ほとんどのプロジェクトでは設定不要です。
# Zero-config validation
i18n-validate ./locales
# JSON output for scripting
i18n-validate ./locales --format json | jq '.summary'
# CI/CD with JUnit XML
i18n-validate ./locales --format junit -o i18n-report.xmlCI/CD 統合
プルリクエストのパイプラインに翻訳検証を追加します。このツールは、GitHub Actions のテストレポーター、GitLab CI のアーティファクト、および JUnit に対応するあらゆる CI システムと統合できる JUnit XML を出力します。
name: Validate Translations
on:
pull_request:
paths: ['locales/**', 'public/locales/**']
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate translations
run: npx @i18n-agent/i18n-validate ./locales --format junit -o i18n-report.xml
- uses: dorny/test-reporter@v1
if: always()
with:
name: i18n validation
path: i18n-report.xml
reporter: java-junit--strict to also fail on warnings.対応形式
i18n-convert を基盤とするこのバリデーターは、32 種類の i18n ファイル形式に標準対応しています。形式ごとのプラグインや設定は必要なく、ファイル拡張子と内容から形式を自動検出します。
Mobile & Desktop
Android XML, Xcode String Catalog, iOS Strings, iOS Stringsdict, Flutter ARB, Qt Linguist
Web & Frameworks
Structured JSON, i18next JSON, JSON5, HJSON, YAML (Rails), YAML (Plain), JavaScript, TypeScript, PHP/Laravel, NEON
Standards & Exchange
XLIFF 1.2, XLIFF 2.0, Gettext PO, TMX, .NET RESX, Java Properties
Data & Other
CSV, Excel (.xlsx), TOML, INI, SRT Subtitles, Markdown, Plain Text
設定
ほとんどのプロジェクトでは設定不要で動作します。チェックの重大度を上書きする、想定言語を指定する、作業中の言語を除外するなど、詳細な制御が必要な場合は、プロジェクトルートに .i18n-validate.toml ファイルを作成します。
# .i18n-validate.toml
ref = "en"
expect = ["de", "ja", "fr", "es", "zh-Hans", "pt-BR", "ko"]
[checks]
missing-keys = "error"
extra-keys = "error"
placeholders = "error"
empty-values = "warning"
untranslated = "warning"
[languages.ko]
missing-keys = "warning" # Korean is WIP
[languages.ar]
skip = true # Exclude from validationi18n Agent を今すぐ試す
翻訳ファイルをここにドロップ
JSON, YAML, PO, XML, CSV, Markdown, Properties
またはクリックしてファイルを選択
翻訳先言語