Linting Translations
What is it?#
A CLI tool that scans your translation files for any issues. It compares all locales against your "source of truth" (default is en) to find missing keys, type mismatches, and other structural mess-ups.
Example#
Imagine you have this structure:
en.yaml (Original):
greeting: "Hello, World!"
menu:
save: "Save"
open: "Open"
items:
- "Apple"
- "Banana"
placeholder: "Hello {name}!"
fr.yaml (Translation with errors):
# 'greeting' is missing
menu: "Menu" # Type mismatch: expected dict, got string
items:
- "Pomme"
# List length mismatch (missing the 2nd element)
placeholder: "Bonjour" # Missing placeholder {name}
extra_key: "Why am I here if I'm not in the original?" # Extra key
Run the lint:
Results#
Core Checks: The tool will spit out a log with all the problems found.
Missing Keys: Finds stuff that exists in the original but is missing in the translation.
Type Mismatches: Ensures that data types (strings, lists, dicts) match everywhere.
List Integrity: Checks list lengths and their structure.
Extra Keys: If there are keys in the translation that don't exist in the original, the linter will give you a warning.
Placeholder Validation (Formatted Strings): The linter automatically checks that you haven't forgotten any variables.
Options#
Change the Source of Truth: You can specify a different locale as the reference (default is en).
ICU MessageFormat Validation: If you're using ICU (plurals, selects, etc.), add this flag for deep syntax checking, tag validation, and placeholder matching inside ICU messages.