Internationalization Route

Anyone ever succeeded in internationalizing routes emberjs?

Do you mean routing /books/12, /libros/12, and /書/12 all to the BookRoute? Ember-I18n doesn’t have anything built-in for that, but you could use it to accomplish what you want:

App.Router.map(function() {
  this.route( 'books', { path: I18n.t('route.books') });
});

That would make it difficult to share links from one language to another, though. (If I sent you a link to /libros/12, your router might not have that.) I don’t have a good solution off the top of my head for mapping all languages’ routes for each user.

@jamesarosen have used your solution and extending it a bit more to further simplify use.

I was wanting to internationalize the route without changing the path.

example:

https://gist.github.com/alexferreira/d3c8191c9aca706f352b

thus leaving more transparent

I think you would need to do this within an instance-initializer. I don’t know how you would do it otherwise.

// app/instance-initializers/i18n-route.js
import Ember from 'ember';

export default {
  name: 'i18n-register-translations',
  initialize(instance) {
    let i18n = instance.container.lookup('service:i18n');
    let Router = instance.container.lookupFactory('router:main');

    // will not interfere with your router.js
    // the results of both maps are automatically joined
    Router.map(function() {
      this.route('books', { path: I18n.t('route.books') });
    });
  }
};