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: about 1 year 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 (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-03-14T23:59:30.000Z (over 3 years ago)
- Last Synced: 2025-04-14T20:18:30.294Z (about 1 year ago)
- Topics: i18n, i18next, i18next-scanner, webpack
- Language: JavaScript
- Size: 2 MB
- Stars: 12
- Watchers: 3
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## i18next-scanner-webpack
[](https://www.npmjs.com/package/i18next-scanner-webpack) []()
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)