Open Rincewind3d opened 7 years ago
Hi, the current version works only with the string literals as an argument as you found earlier and skips other combinations (binary expressions and e.t.c.). Thats why the function call __()
remains untouched which results in exception.
I did a small modification in https://github.com/webpack-contrib/i18n-webpack-plugin/pull/58 which provides possibility to use string concatenation (BinaryExpressions) and templated strings (TemplateLiteral) with variables also. But it requires some time for review and to land into the master.
Hello,
this may be a basic problem/limitation from Webpack, but perhaps someone has an idea.
If i18n is called with a string concatenation Webpack throws an reference error.
I checked the i18n-webpack-plugin code and figured out the the problem is
this.evaluateExpression(expr.arguments[0])
which is not working if there's string concatenation. My knowledge about webpack plugins is limited, perhaps someone has an idea?The use for this string concatenation is in combination with the html-webpack-plugin. For each site I define a template variable with the name of the site and use it to get the translation for the header title.
Yeah, es6 template would be better. But as in https://github.com/webpack-contrib/i18n-webpack-plugin/issues/6 described it's not working.