2.0.5 • Published 6 months ago
i18extract-deno v2.0.5
fork of i18extract to be compatible with deno
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 locales
This command searches the
src
folder 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 --lint
This 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!