问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/50829199/how-to-use-i18next-to-localise-my-website