liuliangsir / babel-plugin-i18next-extract

Babel plugin that statically extracts i18next and react-i18next translation keys.

Home Page:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool



License: MIT Build Status Netlify Status Test Coverage


babel-plugin-i18next-extract is a Babel Plugin that will traverse your Javascript/Typescript code in order to find i18next translation keys.


  • ✅ Keys extraction in JSON v3 format.
  • ✅ Detection of i18next.t() function calls.
  • ✅ Full react-i18next support.
  • ✅ Plurals support.
  • ✅ Contexts support.
  • ✅ Namespace detection.
  • ✅ Disable extraction on a specific file sections or lines using comment hints.
  • ✅ Overwrite namespaces, plurals and contexts on-the-fly using comment hints.
  • … and more?


You can check out the full documentation at

Quick Start


yarn add --dev babel-plugin-i18next-extract

# or

npm i --save-dev babel-plugin-i18next-extract

Minimal configuration

If you don't have a babel configuration yet, you can follow the Configure Babel documentation page to get started.

Declare the plugin like any other plugin in your .babelrc and you're good to go:

  "plugins": [
    // […] your other plugins […]

You may want to specify additional configuration options:

  "plugins": [
    ["i18next-extract", {"nsSeparator": "~"}],
    // […] your other plugins […]

For an exhaustive list of configuration options, check out the Configuration page.

Once the plugin is setup, you can build your app normally or run Babel through Babel CLI:

yarn run babel -f .babelrc 'src/**/*.{js,jsx,ts,tsx}'

# or

npm run babel -f .babelrc 'src/**/*.{js,jsx,ts,tsx}'

Extracted translations land in the extractedTranslations/ directory by default.


Babel plugin that statically extracts i18next and react-i18next translation keys.

License:MIT License


Language:TypeScript 81.5%Language:JavaScript 18.5%