i18next check for unused translation

Viewed 1477

I'm wondering if anyone knows of a good way / tool / package to checking for unused translations

I've seen it for rails, like i18n-tasks but nothing for react

I'm currently using react-i18next, but it could be anything that looks through your translation file

Thanks so much in advance

4 Answers

List unused translations keys

There is i18-unused library which prints list of all unused keys for all json files.

npm install --save-dev i18n-unused

To make it work make sure you add config i18n-unused.config.js in root directory with path to your locales (localesPath) and all js files (srcPath).

//i18n-unused.config.js
module.exports = {
  localesPath: 'src/locales',
  srcPath: 'src',
};

Then run:

i18n-unused display-unused

I use react-18next frequently, and I don't believe there is a tool to check for this. Although, is it necessary? The performance losses are probably negligable.

I used i18next-scanner. It can remove unused translations (see removeUnusedKeys options).

Related