webpack-contrib / i18n-webpack-plugin

[DEPRECATED] Embed localization into your bundle
MIT License
317 stars 74 forks source link

'__' is not defined in Reactjs #75

Closed jackdiff closed 6 years ago

jackdiff commented 6 years ago

Sorry about my bad explainion, but I get a trouble when use i18n-webpack-plugin in my small project using Reactjs.

const path = require('path');
const webpack = require('webpack');
const I18nPlugin = require("i18n-webpack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

const language = require(paths.langPath);

module.exports = {
  entry: "./index.js",
  output: {
    filename: 'static/js/bundle.js',
  },
  resolve: {
    modules: ['node_modules', paths.appNodeModules, 'js'].concat(
      process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
    ),
    plugins: [
      new I18nPlugin(language),
      new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
    ],
  },
}

In jsx file, I use : <span>{__('test')}</span> But when run build I get the error : __(...) is not defined. Can anyone help me resolve this problem ? Thanks