Time to Take off the Gloves

It is Bastille Day here in France. On this, the most important commemorative day in the country, we remember the bloody uprising in which the monarchy was overthrown and a new era of democracy could…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Making the Webpack i18n plugin play nicely with template strings and variables

To put this into context, the example below shows the content of a console log would vary depending on which output you viewed, but the source JavaScript (app.js) stays the same.

app.js:

en.json:

nl.json:

Our Webpack config now looks a little like this:

I wanted to declare a function within the providePlugin but it seemed to only accept a path, so I moved the simple function into a separate file. The bin/helpers/webpack-vocab.js just contains a function which looks something like:

Hey Presto! We can now use code like

Hopefully, this will help if you decide to make use of the i18n plugin for your own projects.

Add a comment

Related posts:

How Small Food Companies Could Benefit from Greater Diversity

Big data may offer a competitive advantage for businesses that can now adapt quickly to changing markets. But for smaller businesses without such data abundance, can diversity strategy offer a reasonable alternative?

Efficient training of Deep Learning jobs on the cloud with datasets consisting of many small files

In this study we address the problem of how to efficiently train deep learning models on machine learning cloud platforms, e.g. IBM Watson Machine Learning, when the training dataset consists of a…

Virtual machine subscriptions like the Shadow PC are the future

Imagine that you can play any current pc game in ultra details, render videos via your smartphone or do processing-heavy tasks on your mom’s crappy 8 or 10 year old laptop. Sounds unrealistic? No, it…