Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gilbsgilbs/babel-plugin-i18next-extract
Babel plugin that statically extracts i18next and react-i18next translation keys.
https://github.com/gilbsgilbs/babel-plugin-i18next-extract
babel-plugin extractor i18n i18next internationalization react react-i18next static-analysis
Last synced: 3 days ago
JSON representation
Babel plugin that statically extracts i18next and react-i18next translation keys.
- Host: GitHub
- URL: https://github.com/gilbsgilbs/babel-plugin-i18next-extract
- Owner: gilbsgilbs
- License: mit
- Created: 2019-06-23T12:22:48.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-14T13:51:45.000Z (2 months ago)
- Last Synced: 2024-09-14T23:48:46.214Z (2 months ago)
- Topics: babel-plugin, extractor, i18n, i18next, internationalization, react, react-i18next, static-analysis
- Language: TypeScript
- Homepage: https://i18next-extract.netlify.com
- Size: 2.08 MB
- Stars: 159
- Watchers: 6
- Forks: 37
- Open Issues: 42
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
![Logo](./docs/assets/imgs/babel-plugin-i18next-extract.png)
# babel-plugin-i18next-extract
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![CI](https://github.com/gilbsgilbs/babel-plugin-i18next-extract/actions/workflows/main.yml/badge.svg)](https://github.com/gilbsgilbs/babel-plugin-i18next-extract/actions/workflows/main.yml)
[![Netlify Status](https://api.netlify.com/api/v1/badges/c3597f83-d80e-428e-b194-f11fe162a893/deploy-status)](https://app.netlify.com/sites/i18next-extract/deploys)
[![Test Coverage](https://api.codeclimate.com/v1/badges/e4badc4fb62625cbff0e/test_coverage)](https://codeclimate.com/github/gilbsgilbs/babel-plugin-i18next-extract/test_coverage)[![NPM](https://nodei.co/npm/babel-plugin-i18next-extract.png?downloads=true)](https://www.npmjs.com/package/babel-plugin-i18next-extract)
---
babel-plugin-i18next-extract is a [Babel Plugin](https://babeljs.io/docs/en/plugins/) that will
traverse your Javascript/Typescript code in order to find i18next translation keys.## Features
- ✅ Keys extraction in [JSONv4 format](https://www.i18next.com/misc/json-format).
- ✅ Detection of `i18next.t()` function calls.
- ✅ Full [react-i18next](https://react.i18next.com/) support.
- ✅ Plurals support.
- ✅ Contexts support.
- ✅ Namespace detection.
- ✅ Disable extraction on a specific file sections or lines using [comment hints](
https://i18next-extract.netlify.app/#/comment-hints?id=disable-extraction-on-a-specific-line-or-code-section).
- ✅ Overwrite namespaces, plurals and contexts on-the-fly using [comment hints](
https://i18next-extract.netlify.app/#/comment-hints?id=explicitly-specify-contexts-for-a-key).
- [… and more?](https://i18next-extract.netlify.app/#/contributing)## Documentation
You can check out the full documentation at [i18next-extract.netlify.app](
https://i18next-extract.netlify.app).## Quick Start
### Installation
```bash
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](
https://babeljs.io/docs/en/configuration) documentation page to get started.Declare the plugin like any other plugin in your `.babelrc` and you're good to go:
```javascript
{
"plugins": [
"i18next-extract",
// […] your other plugins […]
]
}
```You may want to specify additional configuration options:
```javascript
{
"plugins": [
["i18next-extract", {"nsSeparator": "~"}],
// […] your other plugins […]
]
}
```> For an exhaustive list of configuration options, check out the [Configuration](
https://i18next-extract.netlify.app/#/configuration) page.Once the plugin is setup, you can build your app normally or run Babel through [Babel CLI](
https://babeljs.io/docs/en/babel-cli):```bash
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.