How to make i18n with Handlebars.js (mustache templates)?

后端 未结 7 2109
予麋鹿
予麋鹿 2021-01-30 00:30

I\'m currently using Handlebars.js (associated with Backbone and jQuery) to make a web app almost totally client side rendered, and I\'m having issues with the internationalisat

7条回答
  •  别那么骄傲
    2021-01-30 00:38

    Based on @poweratom 's answer :

    Only with ember.js , same with options passed to I18n.js.

    It will magically reload if computed properties are used.

    Ember.Handlebars.helper "t", (str, options) ->
      if I18n? then I18n.t(str, options.hash) else str
    

    Template:

    {{t 'sharings.index.title' count=length}}
    

    Yml:

    en:
      sharings:
        index:
          title: To listen (%{count})
    

提交回复
热议问题