A tool to automatically detect and remove unused translation keys from i18n files across multiple projects, helping maintain clean and efficient localization in React.js and Next.js.
- Detect unused translation keys in your project.
- Remove unused translation keys from JSON files.
- Supports React.js and Next.js projects.
You can install the package using npm:
npm install translation-key-purge
Or using yarn:
yarn add translation-key-purge
Create a sumit.config.json
file in the root of your project to customize the behavior of the package.
{
"functionName": "t",
"languageCode": "en",
"searchPath": "src"
}
-
functionName
: The function name used for translation keys in your code(default: t)
. -
languageCode
: The language code for the JSON file to check(default: en)
. -
searchPath
: The searchPath for the JSON file source folder path to check(default: src)
.
-
Create a
sumit.config.json
file in the root of your project with the desired configuration. -
Add the following script to your
package.json
:
"scripts": {
"check-keys": "translation-key-purge start"
}
- Run the script in your
terminal
:
npm run check-keys
- Follow the prompts to remove unused translation keys.
This project is licensed under the MIT License. See the LICENSE file for details.
Sumit Mayani