0.9.1 • Published 2 years ago

i18next-scanner-webpack v0.9.1

Weekly downloads
1,073
License
MIT
Repository
github
Last release
2 years ago

i18next-scanner-webpack

npm Build Status

This is a simple i18n-scanner webpack-plugin. Based on this package: i18next-parser.

Example webpack.config.js

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:

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.

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
    })
  ]
};
NameDescriptiondefaultOptional
srcsource path of files with i18next translations./srcyes
destdestination of translation files./localesyes
optionsall optionsyes
asyncIf true, immediately report back to webpackfalseyes

Available options: here

0.9.1

2 years ago

0.9.0

2 years ago

0.8.3

2 years ago

0.8.2

3 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.6.0

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago