Giter Site home page Giter Site logo

liuliangsir / babel-plugin-i18next-extract Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gilbsgilbs/babel-plugin-i18next-extract

1.0 1.0 0.0 1.85 MB

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

Home Page: https://i18next-extract.netlify.com

License: MIT License

JavaScript 18.55% TypeScript 81.45%

babel-plugin-i18next-extract's Introduction

Logo

babel-plugin-i18next-extract

License: MIT Build Status Netlify Status Test Coverage

NPM


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

Features

  • ✅ 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?

Documentation

You can check out the full documentation at i18next-extract.netlify.com.

Quick Start

Installation

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": [
    "i18next-extract",
    // […] 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-i18next-extract's People

Contributors

aclave1 avatar daniellehuisman avatar dependabot[bot] avatar dprgarner avatar gilbsgilbs avatar greenkeeper[bot] avatar hnryjms avatar jakubriedl avatar joeldenning avatar konclave avatar michelts avatar oaks-view avatar pcorpet avatar renovate-bot avatar robin-hoodie avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.