Hacker News new | ask | show | jobs
by MarineCG40 238 days ago
I recently found a really practical way to detect and fill missing translations when working with i18next and honestly, it saves a ton of time when you have dozens of JSON files to maintain.

Step 1 — Test for missing translations You can now automatically check if you’re missing any keys in your localization files. It works with your CLI, CI/CD pipelines, or even your Jest/Vitest test suite.

Example:

npx intlayer test:i18next

It scans your codebase, compares it to your JSON files, and outputs which keys are missing or unused. Super handy before deploying or merging a PR.

Step 2 — Automatically fill missing translations

You can choose your AI provider (ChatGPT, Claude, DeepSeek, or Mistral) and use your own API key to auto-fill missing entries. Only the missing strings get translated, your existing ones stay untouched.

Example:

npx intlayer translate:i18next --provider=chatgpt

It will generate translations for missing keys in all your locales.

Step 3 — Integrate in CI/CD You can plug it into your CI to make sure no new missing keys are introduced:

npx intlayer test:i18next --ci

If missing translations are found, it can fail the pipeline or just log warnings depending on your config.

Bonus: Detect JSON changes via Git There’s even a (WIP) feature that detects which lines changed in your translation JSON using git diff, so it only re-translates what was modified.

If you’re using Next.js

TL;DR Test missing translations automatically Auto-fill missing JSON entries using AI Integrate with CI/CDWorks with i18next