4
votes

Does EmberJS support translated routes for internationalized apps? Or does it at least make it easy to extend it to support i18n routes? Anybody with experience with this?

E.g. can the route string be somehow set dynamically from locale files? Also it would be cool when using Ember with Rails routing would not have to be specified twice... is that so?

I'm new to Ember (currently evaluating js frameworks) but I assume in general with Rails one would simply specify very basic routes from within Rails and the rest in Ember? So there wouldn't be much duplication? Wonder if locale files from Rails could be used to lookup route translations.

As a more general question: does Ember has any support for I18n already?

3
Relevant question about I18n: stackoverflow.com/questions/8762456/…pangratz
Why would you want to create internationalized routes? I can't think of an use case, so I'm just wondering.pangratz
Well, in an internationalized app with "pretty", readable urls. Like e.g. /article/a-great-article would become in german: /artikel/ein-toller-artikelNico
Basically you would want this for seo and a native language app feeling for users.Nico

3 Answers

6
votes

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

You have to make sure that the Ember.STRINGS is defined before your router is initialized. The String lookup itself can be done by the loc method, as mentioned 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());
    }
});
4
votes

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

It'll help you with your strings, but there isn't a solution for dealing with translated URLs currently.

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.

3
votes

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

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

I think this is not a complete i18n support, and there is no one built in emberjs.