Globalization approach for ruble cards Ember.js

I am trying to use ember.js in my Rails application.

This raises the issue of globalizing the contents of the handlerbars view template.

Should I try to create myview.handlebars.erb and get the lines translated on the server side (havent tried this), or do I need to create separate descriptor templates for each language (this does not look like DRY if there is no cleaner way)

What is the perfect way to do this?

+4
source share
2 answers

Ember-I18n provides a solution: https://github.com/jamesarosen/ember-i18n

+4
source

Did you get this job for your satisfaction?

Another alternative (we use http://travis-ci.org ) is i18n-js. We like it because it allows you to save all your localizations in one place (config / locales / [x] .yml) and automatically add them to your resource path.

Part of this DRY stuff;)

The syntax in your descriptors is pretty much the same, we're just a handlebars helper

Handlebars.registerHelper('i18n', function(key) { return new Handlebars.SafeString(I18n.t(key)) }); 

and then {{i18n "path.to.translation"}} in the handle view.

+6
source

Source: https://habr.com/ru/post/1396837/


All Articles