我有一个非常简单的网站,没有后端只是纯HTML页面。
我需要为这个网站提供英文/中文版本, 我需要实现的是在NavBar上有一个按钮,当用户点击此按钮时,整个网站上的措辞将改为中文/英文。
我看到的所有例子都需要这样的东西:
localize(".nav");
这是否意味着我需要做这样的事情:
localize("body");
为了让整个网站语言切换?
请帮忙。
感谢。
答案 0 :(得分:1)
根据文档,这里是supported-frameworks的列表。由于您的项目是基本的HTML项目,因此您应该使用此https://github.com/mthh/loc-i18next。在TAG上初始化模块时,我应该确保<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8" />
<title>Sample Title</title>
<link href="/css/design.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h3>Lorem ipsum</h3>
<ol>
<li>www.babyshark.com is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type
specimen book. It has survived not only five centuries, but also the leap into electronic typesetting,
remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets
containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus
PageMaker including versions of Lorem Ipsum.</li>
</ol>
</body>
</html>
属性具有需要转换的字符串键。因此data-i18n="myKey"
应该翻译整个机构,但您必须使用字符串键将localize("body");
属性添加到每个标记