Javascript Multiilingual Text solution
1038 ワード
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript"src="[PATH]/jquery.js"/> // optional
<script type="text/javascript"src="[PATH]/i18next.js"/>
<script>
// translate
var options = {
fallbackLng: null,
fallbackOnNull: false,
cookieName: 'lang',
};
i18n.init(options);
$(function () {
$(".nav #home").text(i18n.t("nav.home"));
});
</script>
</head>
<body>
<header>
<ul class="nav">
<li id="home">HOME</li>
</ul>
</header>
</body>
</html>
loaded resource file (locales/en/translation.json):
{
"nav":{
"home":" ",
}}