将i18next值放在变量JS中
我有一个JS代码,该代码在一段时间后会更改文本,并且我想使用I18Next翻译,以使“性能,灵活性”等单词超过1个语言。我必须解决的想法是将i18next值放在变量中,并用变量将JS代码中的单词替换。但是我不知道如何使用i18next将他的翻译单词放入变量中,如果有人可以帮助我,我会非常感激!
JSON文件
EN-US
"index" : {
"performance" : " performance",
"flexibility" : "flexibility"
}
PT-PT
"index" : {
"performance" : " Desempenho",
"flexibility" : "Flexibilidade"
}
JS代码
var typed1 = new Typed('#typed1', {
strings: ["performance", "flexibility", "scalability."],
typeSpeed: 50,
backSpeed: 20,
smartBackspace: true,
loop: true
});
var typed1 = new Typed('#typed2', {
strings: ["Protection", "Sophisticated", "Flexibility"],
typeSpeed: 100,
backSpeed: 50,
smartBackspace: true,
loop: true
});
I have a JS code that changes the text after some time and I want to use i18next translations in that to make the words "performance, flexibility" etc.. be in more than 1 language. the idea I had to solve this was putting the i18next value inside a variable and substitue the words in the JS code with the variables. but I don't know how to use i18next to put his translated words inside a variable, if someone could help me I would be very grateful!
Json files
en-US
"index" : {
"performance" : " performance",
"flexibility" : "flexibility"
}
pt-PT
"index" : {
"performance" : " Desempenho",
"flexibility" : "Flexibilidade"
}
JS code
var typed1 = new Typed('#typed1', {
strings: ["performance", "flexibility", "scalability."],
typeSpeed: 50,
backSpeed: 20,
smartBackspace: true,
loop: true
});
var typed1 = new Typed('#typed2', {
strings: ["Protection", "Sophisticated", "Flexibility"],
typeSpeed: 100,
backSpeed: 50,
smartBackspace: true,
loop: true
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论