2

私はハンドルとRubyのI18N-jsから GEM(Railsの3アプリ上)を使用して、クライアント側での私の国際化キーを翻訳したいと思います。あなたによれば、このようなハンドルバーのヘルパーは何ですか?現在のハンドルバーのバージョン、デフォルトのヘルパーよるHandlebars.js&I18N-jsから、新しいヘルパー

は、次のようになります。I18N-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); 
}); 

、素敵なcombinaisonのようです。このlibは、Ember.js(ember-i18nなど)の内部で使用されます。 Handlebars.jsとi18nについてはすでにベストプラクティスがありますか?

ありがとうございます。

答えて

関連する問題