I would like to translate my i18n keys on client side using Handlebars and Ruby's i18n-js gem (on a Rails 3 app). According to you, what could be a such Handlebars helper?
According the current Handlebars version, default helpers looks like:
Handlebars.registerHelper('if', function(context, options) {
var type = toString.call(context);
if(type === functionType) { context = context.call(this); }
if(!context || Handlebars.Utils.isEmpty(context)) {
return options.inverse(this);
} else {
return options.fn(this);
}
});
Handlebars.registerHelper('unless', function(context, options) {
var fn = options.fn, inverse = options.inverse;
options.fn = inverse;
options.inverse = fn;
return Handlebars.helpers['if'].call(this, context, options);
});
Handlebars.registerHelper('with', function(context, options) {
return options.fn(context);
});
Handlebars.registerHelper('log', function(context) {
Handlebars.log(context);
});
About i18n-js gem, it seems to be a nice combinaison. This lib is for instance used inside Ember.js (as ember-i18n). Is there already a best practice about Handlebars.js and i18n?
Thank you for any suggestions.