Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ph1p/i18next-scanner-webpack
Simple i18n-scanner webpack plugin
https://github.com/ph1p/i18next-scanner-webpack
i18n i18next i18next-scanner webpack
Last synced: 3 months ago
JSON representation
Simple i18n-scanner webpack plugin
- Host: GitHub
- URL: https://github.com/ph1p/i18next-scanner-webpack
- Owner: ph1p
- License: mit
- Created: 2017-11-24T14:53:33.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-14T23:59:30.000Z (almost 2 years ago)
- Last Synced: 2024-11-02T08:11:41.552Z (3 months ago)
- Topics: i18n, i18next, i18next-scanner, webpack
- Language: JavaScript
- Size: 2 MB
- Stars: 12
- Watchers: 4
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## i18next-scanner-webpack
[![npm](https://img.shields.io/npm/v/i18next-scanner-webpack.svg)](https://www.npmjs.com/package/i18next-scanner-webpack) [![Build Status](https://github.com/ph1p/i18next-scanner-webpack/workflows/Test%20and%20publish%20to%20npm/badge.svg)]()
This is a simple i18n-scanner webpack-plugin.
Based on this package: [i18next-parser](https://github.com/i18next/i18next-parser).**Example webpack.config.js**
```javascript
const path = require('path');
const i18nextWebpackPlugin = require('i18next-scanner-webpack');module.exports = {
mode: 'development',
entry: path.resolve(__dirname, './src/index.js'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js'
},
plugins: [
new i18nextWebpackPlugin({
// src defaults to ./src
// dest defaults to ./ (project root folder)
// default ['.js', '.jsx', '.vue']
extensions: ['.js', '.jsx']
// See options at https://github.com/i18next/i18next-parser#options
options: {
lexers: {
js: [{
lexer: 'JavascriptLexer',
// default ['t']
functions: ['t', '$t', 'i18next.t', 'i18n.t'],
}]
},
locales: ['en', 'de'],
// defaults to locales/$LOCALE/$NAMESPACE.json
output: '$LOCALE/$NAMESPACE.json'
}
})
]
};
```**Minimal setup:**
```javascript
const path = require('path');
const i18nextWebpackPlugin = require('i18next-scanner-webpack');module.exports = {
mode: 'development',
entry: path.resolve(__dirname, './src/index.js'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js'
},
plugins: [
new i18nextWebpackPlugin({
options: {
locales: ['en', 'de']
}
})
]
};
```**Faster dev loops:**
If `async` option is `true`, the plugin will not wait for `i18next-scanner` to finish before reporting back to webpack. Useful in large projects or when using an expensive `transform`.
```javascript
const path = require('path');
const i18nextWebpackPlugin = require('i18next-scanner-webpack');module.exports = {
mode: 'development',
entry: path.resolve(__dirname, './src/index.js'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js'
},
plugins: [
new i18nextWebpackPlugin({
options: {
locales: ['en', 'de']
},
async: true
})
]
};
```| Name | Description | default | Optional |
| --------- | ---------------------------------------------- | --------- | -------- |
| src | source path of files with i18next translations | ./src | yes |
| dest | destination of translation files | ./locales | yes |
| options | all options | | yes |
| async | If true, immediately report back to webpack | false | yes |Available options: [here](https://github.com/i18next/i18next-parser#options)