0

I have a working webpack config which can generate i18n bundles. I am using i18n-webpack-plugin. My website is a static website. I can see the bundles generated as [language].[name].bundle.js. eg: "de.login.bundle.js", "en.login.bundle.js".

Now in my login html page, how do I decide which of these bundles to load ? I will provide my users an option for language selection, say in top nav bar. Once user has selected it, how do I load the appropriate language bundle?

Manish
  • 146
  • 4
  • 12

1 Answers1

0

I found a solution to achieve this using HtmlWebpackPlugin :

new HtmlWebpackPlugin({
                filename: language + '/login.html',
                template: 'html/login.html',
                chunks: ['login']
            })

This generates separate Html files under each language directory eg: en/login.html, de/login.html. Now , based on the user's language selection, he can be redirected to appropriate URL.

I would still be interested to know if there's any alternate way to achieve this.

Manish
  • 146
  • 4
  • 12