Franva
Franva

Reputation: 7077

How to use i18next to localise my website?

I have a very simple website with no backend, just pure html pages.

I need to have English/Chinese versions for this website, what I need to achieve is have a button on NavBar, when users click this button, the wording on entire website will be changed to Chinese/English.

All the examples I have seen that they are all require something like this:

localize(".nav");

So does it mean that I need to do something like this:

localize("body");

in order to get the whole website language switched?

Upvotes: 0

Views: 647

Answers (1)

Ulrich Dohou
Ulrich Dohou

Reputation: 1559

According to the doc here is the list of supported-frameworks. As your project is a basic HTML one you should use this https://github.com/mthh/loc-i18next. When you init the module on a TAG you should me make sure there is the data-i18n="myKey" attribute with the key of string that need to be translated. So localize("body"); should translate the whole body but you must add the data-i18n attribute to each tag with a string key

Upvotes: 1

Related Questions