1

是否可以使用 ember.js 在 URL 中添加全局语言代码前缀?例如

/#/en/about
/#/de/about

换句话说

/#/{language_code}/whatever/is/there/...
4

1 回答 1

3

当然,您可以将您的路线嵌套在lang这样的资源中。

App.Router.map(function() {
  this.resource('lang', { path: '/:lang_id' }, function() {
    this.route('about');
  });
});

然后,您可以使用这些路线,{{linkTo}}例如,

{{#linkTo 'about' 'en'}}About (en){{/linkTo}}
{{#linkTo 'about' 'de'}}About (de){{/linkTo}}
于 2013-07-04T16:43:21.233 回答