Translation Files Validation in Angular with Transloco
Written by Shahar Kazaz, Co-Creator & maintainer of Transloco

![]()


When building enterprise Angular apps with multiple teams, merge conflicts in translation files are inevitable. A tiny mistake—like an extra comma—can break your JSON, and the error might go unnoticed until it's shipped:
{
"key": "",
"keyTwo": "", 👈
}Suddenly, your app is broken in staging or production because of an invalid translation file. It’s a classic case of “it worked on my machine”—but not for your users.
To avoid these headaches, the @jsverse/transloco-validator linter will:
Validate your translation files (catching syntax errors)
Detect duplicate keys
You can run this validation in two ways: as a pre-commit hook or as a CI job in GitHub Actions.
Option 1: Validate on Pre-Commit with Husky & lint-staged
This approach prevents broken translation files from ever making it into your repository.
Install the validator as a dev dependency:
Set up Husky and lint-staged: To ensure your translation files are always valid, configure Transloco Validator to run on specific paths during pre-commit checks. You can easily set this up in your
lint-stagedconfiguration.lint-stagedsupports multiple configuration formats. All you need to do is add the following line to the configuration of your choice:
Now, every time someone tries to commit changes to translation files, the linter runs automatically. If there’s an error (invalid JSON or duplicate keys), the commit will be blocked until it’s fixed.
Option 2: Validate in CI with GitHub Actions
Prefer to catch issues on every push or pull request? You can run transloco-validator in your CI pipeline instead.
Install the validator as a dev dependency:
Create a GitHub Actions workflow (e.g.,
.github/workflows/validate-i18n.yml):
With this setup, every PR will fail if the translation files are invalid or contain duplicate keys, keeping your main branch safe.
Why Validate Translation Files?
Catch errors before they hit users
Automate best practices across teams
Reduce manual QA and firefighting
Conclusion
Broken translation files are a preventable risk. Whether you use a pre-commit hook with Husky or automate validation in your CI, the @jsverse/transloco-validator helps keep your app’s translations bulletproof.
Was this helpful?

