jknack/handlebars.java

Passing language to i18n from outside template

andr3aLucch3si85 opened this issue · 0 comments

Hi. I have a template.html and I want to use i18n function to translate some titles. I can't put the language in template because I need to change it every time I use the template.

I can't use template.apply to inject an object with language because I use it to put another object in context.

Is there any way to inject language from outside template. I try this:

Define an helper:

public String getLang() { return lang; }

Then I use it:

<div class="card-title">{{i18n "wishlist" locale={{getLang}} }}</div>

But I receive this error:

com.github.jknack.handlebars.HandlebarsException: /templates/template.html:13:61: found: '{' <div class="card-title">{{i18n "wishlist" locale={{getLang}} }}</div>

Could you help me?