How to use i18next to localise my website?

大憨熊 提交于 2019-12-13 02:58:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!