【发布时间】:2013-07-02 17:24:43
【问题描述】:
是否可以使用 ember.js 在 URL 中添加全局语言代码前缀?例如
/#/en/about
/#/de/about
换句话说
/#/{language_code}/whatever/is/there/...
【问题讨论】:
标签: url localization ember.js routes url-routing
是否可以使用 ember.js 在 URL 中添加全局语言代码前缀?例如
/#/en/about
/#/de/about
换句话说
/#/{language_code}/whatever/is/there/...
【问题讨论】:
标签: url localization ember.js routes url-routing
当然,您可以像这样将路由嵌套在 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}}
【讨论】:
lang_id 来设置I18n.locale?
params.lang_id 在对应的model 钩子中LangRoute。