I18n in EmberJS (routing and in general)

Does EmberJS support route translation for internationalized applications? Or at least simplify its extension to support i18n routes? Anyone who has experience?

eg. can a route string be dynamically configured from locale files? It would also be great when using Ember with Rails routing would not need to be specified twice ... is that so?

I'm new to Ember (currently evaluating js frameworks), but I assume that in general with Rails, you can just specify very simple routes from Rails and the rest to Ember? So there won't be a lot of duplication? I wonder if the locale files from Rails can be used to find route translations.

As a more general question: Does Ember already have I18n support?

+4
source share
3 answers

You can achieve internationalized routes by re-opening Ember.Route and setting up a localized route when it is initialized, see the example here http://jsfiddle.net/pangratz666/wQXvb/ .

You must ensure that the Ember.STRINGS parameter Ember.STRINGS defined before the router initializes. A search for the string itself can be performed using the loc method, as indicated by sly7_7 .

 Ember.STRINGS = { '/all': '/alle', '/home/:id': '/zuhause/:id' }; Ember.Route.reopen({ init: function() { this._super(); var route = this.get('route'); if (route) this.set('route', route.loc()); } }); 
+6
source

There is a project ember-i18n: https://github.com/zendesk/ember-i18n

This will help you with your strings, but there is currently no solution for working with translated URLs.

You can use any JS routing library with Ember. There's a pretty simple Ember.Location protocol for integrating your own routing library with Ember.Router .

+4
source

A partial answer for a general question can be found here:

http://docs.emberjs.com/#doc=Ember.String&method=.loc&src=false

I think this is not full i18n support, and there is no one in emberjs.

+3
source

All Articles