【发布时间】:2017-07-22 08:43:48
【问题描述】:
这是我第一次使用 i18next,我不知道如何让它工作。 (似乎documentation 对我来说不完整) 这是我的带有 i18next 的 HTML 代码
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/i18next/4.0.0/i18next.min.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-i18next/1.1.0/jquery-i18next.min.js"></script>
<script src="/i18nextXHRBackend.min.js"></script>
</head>
<body>
<div id="test">
<a data-i18n="Hello"></a>
<div data-i18n="World"></div>
</div>
<script>
i18next
.init({
"debug": true,
"lng": "en",
"ns": [
"translation"
],
"fallbackLng": false,
"keySeparator": false,
"nsSeparator": false,
resources: {
"backend": {
"loadPath": "locales/{{lng}}/{{ns}}.json"
}
}
}, function(err, t) {
jqueryI18next.init(i18next, $);
$('#test').localize();
});
</script>
</body>
</html>
这是我的 JSON:
{ "Hello" : "Hello in English", "World" : "World in English" }
我的页面中没有显示,在控制台中我有这个
i18next::translator: missingKey en translation Hello
i18next::translator: missingKey en translation World
我错过了什么吗?
【问题讨论】:
标签: i18next