2

我想利用把手和客户端Ruby的国际化-JS宝石翻译(上一个Rails 3应用程序)我的i18n键。据你介绍,可能是一个这样的把手帮手?Handlebars.js和国际化,JS,新的辅助

根据当前把手版本,默认助手的样子:

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); 
}); 

关于国际化JS的宝石,这似乎是一个不错的combinaison。这个库在Ember.js中用作实例(如ember-i18n)。 Handlebars.js和i18n已经有最佳做法了吗?

谢谢你的任何建议。

回答