Open kimown opened 7 years ago
you can always make another function that suits your needs, then shove the translated strings together with placeholders into your custom function that will do the replacing
For example:
const language = 'Dutch';
const message = template(__('Hello World, language is %s'), language);
function template(target = '', ...replacements) {
for (let i = 0; i < replacements.length; i++) {
target = target.replace('%s', replacements[i]);
}
return target;
}
Your translation file would look like:
{
"Hello World, language is %s": "Hallo wereld, taal is %s"
}
i18n-webpack-plugin only support
__("Hello World")
, but I want this plugin support format like thisso I make a little change about the source code
, but when I apply webpack.ProvidePlugin, the error occurs.
Here is my code,
yarn install, webpack -w
, then open index.html, you can see the error in Chrome DevTools console. i18n.zipI spent some time trying to fix this problem, but failed, I don't know why this happens. any suggestion will be appreciated, thanks.