问题标签 [i18next]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
608 浏览

i18next - i18next 1.7.2 版无法读取 null 错误的属性“状态”

我在使用 i18next 获取 i18n 版本的字符串时遇到了困难。我在 i18next-1.7.2.js 的第 1381 行无法读取属性“状态”的空错误

我的 json 文件位于 locales/translation-en.json,... 等。

我的初始化代码如下:

无法读取 null (javascript) 的属性“长度”不适用于我的案例。

0 投票
2 回答
1339 浏览

javascript - 如何在不删除 cookie 的情况下重新加载页面

我正在做一个网络应用程序,并且我已经在用户可以选择更改应用程序语言的部分,例如。从 en-US 到 ja,我使用的是 i18next。我所做的是将用户的首选语言写入 cookie,重新加载页面,然后读取我使用用户首选语言创建的 cookie。但是它不起作用,因为似乎每次重新加载页面时,我创建的 cookie 都会被删除,因此它会恢复为默认语言。

问题是有没有办法在不删除我制作的 cookie 的情况下重新加载页面?

0 投票
1 回答
393 浏览

html - HTML的i18next和lang属性的区别?

我被要求进行应用程序的内部化。因此,我进行了研究,发现 i8next 基本上可以满足我的需求。

i18next是一个功能齐全的 i18n javascript 库,用于翻译您的 web 应用程序。在浏览器、node.js、rhino 和其他 javascript 运行时运行。” i18next.com

然后我记得你在 html 中有一个选项,即lang属性,用于设置 html 的语言。

有什么不同?我是正确的还是我使用了 18next 或者 attrbute lang 可以轻松解决我的问题?

0 投票
1 回答
215 浏览

javascript - i18next + wordpress - /locales 文件夹的自定义路径

有什么方法可以为i18next调用传递自定义路径吗?locales它在站点根目录中搜索文件夹。但是如果我在 WordPress 插件中使用它,我必须通过我的插件文件夹 url 传递一个自定义路径,因为 wordpress 结构。

0 投票
2 回答
112 浏览

jquery - jquery 移动按钮样式在本地化时丢失

我正在使用本地化库i18Next html 代码处理jquerymobile项目

js代码

现在的问题是文本已更改但按钮样式丢失第二个问题设置带有标签的文本我尝试过页面创建触发器,但它不工作你的建议。这是工作的jsfiddle

0 投票
1 回答
3224 浏览

i18next - i18next - All languages in one .json file

How can I make i18next load all languages from just one file?

I managed to do it by putting each language in a seperate file (translation-en.json, translation-no.json, etc), and also managed to input languages with the resStore option, but putting it all in a seperate .json file is really not documented anywhere (I've searched for 4 hours+ now)

My js code:

My translation.json file:

Ok, so I managed to "hack" it byt putting an object into a seperate .js file, include it in a script tag and loading it using resStore, but that just can't be the best way to use this lib.

0 投票
2 回答
817 浏览

node.js - i18next 错误:ENOENT

我有这个:

在我的 node-express 应用程序中,我的语言环境如下:

我不断ENOENT在控制台中收到消息,例如:

我错过了什么?

另外,在某些情况下,我只想使用后备文件,例如 en-UK,我没有该ns.forms.json文件,所以我得到

解决此问题的正确方法是什么?

任何建议非常感谢

0 投票
3 回答
22439 浏览

javascript - 使用 i18next(占位符,值)翻译自定义属性

我正在研究i18next本地化库的可能性。

现在我有以下代码(完整的小提琴在这里):

HTML

JS

它翻译所有text元素,但问题是我无法翻译custom attributes。例如,div 内的文本已翻译,但我不明白如何翻译自定义属性,如placeholdervalue

另一个问题是我的翻译方式。每当单击按钮ChiEng,我都会初始化翻译(但我不确定这是正确的方法)。编辑我想我找到了解决这个问题的方法(我需要使用 setLng):i18n.setLng(lang, function(t) { ... })

0 投票
4 回答
6128 浏览

javascript - 如何在 i18next 中使用 Knockout observables?

我试图以某种方式动态地将 i18next 翻译与 Knockout.js 一起使用,但我不知道如何。

自定义 Knockout 绑定或 i18next jQuery 插件似乎都不适用于可观察值。

可以在这里找到我想要实现的演示:http: //jsfiddle.net/rdfx2/1/

解决方法是这样的,但如果可能的话,我宁愿避免这种情况:

谢谢,

0 投票
2 回答
4587 浏览

jquery - i18next 初始化的加载顺序

我在让 i18next 正确初始化并提取适当的翻译字符串时遇到了一些问题。有几个库:

  • 电话间隙 3.x
  • 骨干网.js
  • 需要.js
  • i18next.js
  • 车把.js

我的 app.js 具有以下 document.ready 功能:

不幸的是,代码甚至没有达到我设置的 document.ready 断点。相反,router.js 定义首先调用 View 类中的初始化代码:

... Homeview.js:

在页面加载期间,会引发 TypeError:

知道我在这里做错了什么吗?


编辑: app.js 中的 require.config 块(包括垫片):