Translation generation

We provide our own CLI to generate translation files from code

Install CLI

yarn add -D @react3l/i18next-extractor

Extract translation keys:

Usage: i18next-extractor extract [options]

Extract all translations from your source code

Options:
  -i, --input <inputPath>              Input path (default: "src/")
  -o, --output <outputPath>            Output path (default: "public/assets/i18n/")
  -p, --partials <partialPath>         Partial path (default: "public/assets/i18n/partials/")
  -ic, --include <include>             Include pattern (default: "\\.(js|jsx|ts|tsx)$")
  -ex, --exclude <exclude>             Exclude pattern (default: "\\.(spec|test)\\.(js|jsx|ts|tsx)$")
  -ks, --key-separator <keySeparator>  Key separator (default: ".")
  -is, --indent-size <indent>          Indent size (default: 2)
  -l, --languages <languages...>       Supported languages (default: ["en","vi"])
  -m, --marker <marker>                Translate marker (default: "translate")
  -h, --help                           output usage information

Merge translation files into one

Usage: i18next-extractor merge [options]

Merge all translations for each language into a single JSON file

Options:
  -i, --input <inputPath>              Input path (default: "src/")
  -o, --output <outputPath>            Output path (default: "public/assets/i18n/")
  -p, --partials <partialPath>         Partial path (default: "public/assets/i18n/partials/")
  -ic, --include <include>             Include pattern (default: "\\.(js|jsx|ts|tsx)$")
  -ex, --exclude <exclude>             Exclude pattern (default: "\\.(spec|test)\\.(js|jsx|ts|tsx)$")
  -ks, --key-separator <keySeparator>  Key separator (default: ".")
  -is, --indent-size <indent>          Indent size (default: 2)
  -l, --languages <languages...>       Supported languages (default: ["en","vi"])
  -m, --marker <marker>                Translate marker (default: "translate")
  -h, --help                           output usage information