Licence
MIT
Version
3.2.3
Deps
10
Size
21 kB
Vulns
0
Weekly
0
i18extract
A command-line tool for extracting i18next translation keys from your source code and generating translation JSON files using Google Translate APIs.
Badges
Table of Contents
Installation
You can use i18extract directly via npx:
npx i18extract
Usage
To extract translation keys and generate translation files, use the following command:
npx i18extract -l en,es,fr -i src/**/*.{js,jsx,ts,tsx} -o locales
Parameters
-l(required): List of languages to create translations for (separated by commas, e.g.,en,ca,es).-i(required): Input path to search for translation keys (glob patterns can be used).-o(required): Output directory where translation JSON files will be generated.--lint(optional): Checks if every translation key exists in the translation JSON files.
Examples
Basic Usage:
npx i18extract -l en,es,fr -i src/**/*.{js,jsx,ts,tsx} -o localesThis command searches the
srcfolder for translation keys (e.g.,t('Hi')) and generates:locales/en.json{ "Hi": "Hi" }locales/es.json{ "Hi": "Hola" }locales/fr.json{ "Hi": "Salut" }
Using the Linter:
npx i18extract -l en,es,fr -i src/**/*.{js,jsx,ts,tsx} -o locales --lintThis command will check for missing translations:
>> error: no translation found for "Hi"
License
Feel free to let me know if you want to add or modify any sections!