New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use variables with handlebars #199
Comments
http://i18next.com/pages/doc_templates.html is for clientside but might be same for serverside... just be sure to use the t function on request object to assert you get translations in users language. |
Sorry, put the wrong documentation link in there. Here is the right one. I think you understood me wrong, sorry for that. Translation is already working, but variables aren't. (Like names, links etc.) |
not sure but according to http://handlebarsjs.com/expressions.html#helpers you need to use triple {
but not sure as i never used handlebars on serverside. |
@jamuhl Nope, that doesn't work. Thanks for trying to help though! I am adding the maintainers of hbs and handlebars to this so they can maybe help. /cc @kpdecker & @defunctzombie |
That syntax is invalid. You want something like |
I tried it with handlebars.registerHelper('t', function(key, options) {
// The console.log's are added by me
console.log(key)
console.log(options)
var result = i18n.t(key, options);
console.log(result)
return new handlebars.SafeString(result);
}); from the Template Documentation The console log shows: key:
options:
result:
So something isn't working, but I think that the problem is more on my or i18next's side. Any ideas @jamuhl? Cheers, Silas |
I suspect that you want something like:
On Sun, Aug 9, 2015 at 4:02 PM ApfelUser notifications@github.com wrote:
|
@kpdecker Thanks so much! That worked. I am writing it down here for people with the same issue: handlebars.registerHelper('t', function(key, options) {
var result = i18n.t(key, options.hash);
return new handlebars.SafeString(result);
}); @jamuhl Do you maybe want to add this to the documentation? I could too, but didn't find a repository for it. /closing |
yes will add this to doc. thanks to all for solving this. |
closing...handlebars will not be in docs anylonger. hope someone will come up with some plugin for handlebars for v2 of i18next: http://i18next.github.io/i18next.com/docs/ecosystem/#frameworks |
According to the documentation at the templates section it is possible to use variables in Jade like this:
p=t("my.translation.key", { my: "variable" })
how can I make this work with handlebars?
This:
This:
And this:
all crash with:
Is there some helper I need to add? And if yes, which one?
Cheers,
Silas
The text was updated successfully, but these errors were encountered: