react-i18next validator. Validate there are no duplicate keys in translation files. Validate there are no missing keys in code that are provided in translation files. Validate there are no missing keys in translation files that are provided in code files.
Explore the docs »
Report Bug
·
Request Feature
Table of Contents
Stop cluttering translation.json files with keys that are no longer used or duplicate values. Make sure you don't forget to add a key to the translation file when you add it to the code. Make sure you don't forget to remove a key from the translation file when you remove it from the code.
- Install package
npm install react-i18next-validator --save-dev
yarn add -D react-i18next-validator
- Create config file in root directory
ri18next-v.config.js
export const config = {
directory: './public/locales/',
src: './src/'
}
- Add script to
package.json
"scripts": {
"ri18next-v": "ri18next-validator"
}
- Run script
npm run ri18next-v
yarn ri18next-v
- You can add additional options to the config
export const config = {
errorLevel: 'error', // error, warn, info
regex: [/someRegex/g], // RegExp[] array of regex to look for in code files to match translation keys
ignoreKeys: ['foo', 'bar'] // string[] array of keys to ignore
}
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.