Comprehensive verification system for translation files that checks for missing keys and structural compatibility between source and target locales, ensuring translation completeness and consistency.
Note: Verification functionality is only available via the CLI command interface and is not exported for programmatic use.
Runs verification checks on translation files to ensure quality and completeness.
/**
* Verify translation files for completeness and consistency
* @param translation_files - Glob patterns for translation files to verify
* @param --source-locale - The source locale to compare against
* @param --missing-keys - Check for missing keys in target locales
* @param --structural-equality - Check structural consistency between locales
* @param --ignore - Glob patterns to ignore
*/
formatjs verify [translation_files...] --source-locale <locale> [options]interface VerifyOpts {
/** The source locale of the translation files */
sourceLocale: string;
/** Whether to check for missing keys in target locale */
missingKeys: boolean;
/** Whether to check for structural equality between locales */
structuralEquality: boolean;
/** List of glob paths to ignore */
ignore?: string[];
}Verifies that all keys present in the source locale are also present in target locales.
Verifies that message structures (plurals, selects, arguments) are consistent between locales.
# Verify all translations against English source
formatjs verify 'translations/*.json' --source-locale en --missing-keys --structural-equality
# Verify with specific source locale format
formatjs verify 'locales/*.json' --source-locale en-US --missing-keys --structural-equality# Check only for missing translation keys
formatjs verify 'translations/*.json' --source-locale en --missing-keys
# With ignore patterns
formatjs verify 'translations/*.json' --source-locale en --missing-keys --ignore 'translations/test-*.json'# Check only structural consistency
formatjs verify 'translations/*.json' --source-locale en --structural-equality# Verify with multiple ignore patterns
formatjs verify 'translations/**/*.json' \
--source-locale en-US \
--missing-keys \
--structural-equality \
--ignore 'translations/draft-*.json' 'translations/**/test-*.json'
# Verify specific file patterns
formatjs verify 'locales/production/*.json' \
--source-locale en \
--missing-keys \
--structural-equalityEnsures that every message key present in the source locale file is also present in all target locale files. This guarantees that no messages are left untranslated.
Example Issues Detected:
"welcome.title" exists in en.json but missing from fr.jsonEnsures that the ICU MessageFormat structure of messages is consistent between locales. This catches issues where:
Example Issues Detected:
Source (en.json):
{
"cart.items": "{count, plural, one {# item} other {# items}}"
}Target (fr.json) - Invalid:
{
"cart.items": "{count} éléments"
}The French translation is missing the plural structure.
When verification fails, the CLI exits with code 1 and provides detailed error information:
$ formatjs verify 'translations/*.json' --source-locale en --missing-keys --structural-equality
[@formatjs/cli] [ERROR] Missing keys found:
fr.json missing: welcome.subtitle, navigation.home
es.json missing: welcome.subtitle
[@formatjs/cli] [ERROR] Structural equality issues found:
fr.json: cart.items - Missing plural structure
es.json: profile.settings - Missing select options: [theme, language]
Process exited with code 1# In CI/CD pipeline - fail build on verification issues
formatjs verify 'translations/*.json' --source-locale en --missing-keys --structural-equality
if [ $? -ne 0 ]; then
echo "Translation verification failed - blocking deployment"
exit 1
fi# Check only missing keys during active development
formatjs verify 'translations/*.json' --source-locale en --missing-keys
# Full verification before release
formatjs verify 'translations/*.json' --source-locale en --missing-keys --structural-equalityOrganize translation files for effective verification:
translations/
├── en.json # Source locale
├── fr.json # Target locales
├── es.json
├── de.json
└── draft/ # Ignored development files
├── experimental-en.json
└── experimental-fr.jsonUse ignore patterns to exclude development files:
formatjs verify 'translations/*.json' --source-locale en --missing-keys --ignore 'translations/draft/*'