Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Langgenius Dify Check I18n

From Leeroopedia
Knowledge Sources
Domains Frontend, Build_Tools
Last Updated 2026-02-12 07:00 GMT

Overview

JavaScript script that checks i18n key consistency across all supported locale directories, reporting missing and extra keys relative to the en-US reference locale.

Description

check-i18n.js is a CLI validation tool that ensures all supported language translation files stay aligned with the en-US reference locale. It reads every .json file from each locale directory under web/i18n/, flattens the keys with a namespace prefix derived from the filename (converted to camelCase), and compares them against the en-US keys.

The script supports several filtering and automation capabilities:

  • --file -- Restrict checking to specific translation file names (space-separated)
  • --lang -- Restrict checking to specific locale codes (space-separated)
  • --auto-remove -- Automatically delete extra keys from locale files that do not exist in en-US

The supported languages list is loaded dynamically from the i18n-config/languages module, filtering to only those marked as supported.

When differences are detected, the script prints missing and extra keys per language and exits with code 1. With --auto-remove enabled, extra keys are removed in-place from the JSON files and the exit code reflects only remaining missing-key issues.

Usage

Run this script as part of CI or locally before committing i18n changes to verify that all locale files are synchronized with the en-US reference.

Code Reference

Source Location

Signature

function parseArgs(argv)
function printHelp()
async function getKeysFromLanguage(language)
async function removeExtraKeysFromFile(language, fileName, extraKeys)
async function main()
async function bootstrap()

Import

// CLI script - run via pnpm
pnpm run i18n:check [options]

// Or directly
node web/scripts/check-i18n.js [options]

I/O Contract

Inputs

Name Type Required Description
--file <name...> string(s) No Space-separated translation file basenames to check (e.g., app billing)
--lang <locale...> string(s) No Space-separated locale codes to check (e.g., zh-Hans ja-JP)
--auto-remove flag No Automatically remove extra keys from locale files that are not present in en-US
--help / -h flag No Show usage instructions and exit
i18n/<locale>/*.json JSON files Yes Translation files for each supported locale under web/i18n/

Outputs

Name Type Description
stdout string Per-language comparison showing missing keys and extra keys
Modified JSON files JSON files When --auto-remove is active, locale JSON files are updated in-place with extra keys removed
exit code 0 number All i18n files are in sync
exit code 1 number Key mismatches detected, unsupported language specified, or argument parsing errors

Usage Examples

Check all languages for all files

pnpm run i18n:check

Check specific files and languages

pnpm run i18n:check --file app billing --lang zh-Hans ja-JP

Auto-remove extra keys

pnpm run i18n:check --auto-remove

Check a single locale

pnpm run i18n:check --lang zh-Hans

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment