Skip to content

appearhere/i18next-scanner-webpack

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

i18next-scanner-webpack

npm Build Status

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

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({
      // See options at https://github.com/i18next/i18next-scanner#options
      // src defaults to ./src
      // dist defaults to ./locales
      options: {
        func: {
          // default ['i18next.t', 'i18n.t']
          list: ['t', '$t', 'i18next.t', 'i18n.t'],
          // default ['.js', '.jsx', '.vue']
          extensions: ['.js', '.jsx']
        },
        lngs: ['en', 'de'],
        // both defaults to {{lng}}/{{ns}}.json
        resource: {
          loadPath: '{{lng}}/{{ns}}.json',
          savePath: '{{lng}}/{{ns}}.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: {
        lngs: ['en', 'de']
      }
    })
  ]
};
Name Description default Optional
src source path of files with i18next translations ./src yes
dist destination of translation files ./locales yes
options all options yes

Available options: here

About

Simple i18n-scanner webpack plugin

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.5%
  • HTML 0.5%