获取 i18next 翻译器 缺少密钥

Adi*_*mar 7 i18next

这是我第一次使用 i18next,我不知道如何让它发挥作用。(对我来说文档似乎不完整)这是我使用 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>
Run Code Online (Sandbox Code Playgroud)

这是我的 JSON:

{ "Hello" : "英语你好", "World" : "英语世界" }

我的页面中没有显示任何内容,在控制台中我得到了这个

i18next::translator: missingKey en translation Hello

i18next::translator: missingKey en translation World 
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?

jam*_*uhl 7

如果您丢失了,则表明您的 json 文件中的翻译根本未加载。

应该有关于后端无法加载控制台中的警告。

确保:locales/en/translation.json可访问 - 或相应地修复路径