Reputation: 222441
I know that I can use i18next to translate languages in html. For example:
<div data-i18n="someKey"></div>
But is there a way to somehow use it in JS. For example if I want to do something like
alert(someKey)
?
Upvotes: 1
Views: 1511
Reputation: 324600
Having read the homepage of the project...
i18n.init(function(t) { // translate nav $(".nav").i18n(); // programatical access var appName = t("app.name"); });
That last part is what you're looking for. It's important to note that that t
is passed to the init
callback as a parameter - you can't just blindly call t()
anywhere ;)
Upvotes: 1
Reputation: 1343
It should be alert(t(someKey))
(see http://i18next.com/ at end of page).
Upvotes: 1