Angular 9:如何在路由中使用$localize

Angular 9:如何在路由中使用$localize,angular,angular-i18n,angular9,Angular,Angular I18n,Angular9,我正在使用“@angular/localize”:“^9.0.2”,我有一条带有动态标题的路线,应该翻译为: const routes:routes=[ {路径:“概述”,组件:仪表板页面组件,数据:{title:$localize`:@@overview:overview`,breadcrumb:'overview'}, ]; @NGD模块({ 导入:[RouterModule.forChild(路由)], 导出:[路由模块] }) 导出类DashboardRoutingModule{} m

我正在使用“@angular/localize”:“^9.0.2”,我有一条带有动态标题的路线,应该翻译为:

const routes:routes=[
{路径:“概述”,组件:仪表板页面组件,数据:{title:$localize`:@@overview:overview`,breadcrumb:'overview'},
];
@NGD模块({
导入:[RouterModule.forChild(路由)],
导出:[路由模块]
})
导出类DashboardRoutingModule{}
messages.es.xlf


概述
Vista general
但是当我运行
ng serve--configuration=es
时,会显示以下错误:

ERROR in src/app/dashboards/dashboard-routing.module.ts(8,7): Error during template compile of 'DashboardRoutingModule'
  Reference to a local (non-exported) symbols are not supported in decorators but 'routes' was referenced
    Consider exporting 'routes'.
此外,我还阅读了文章:寻找解决方法,例如:

const routes:routes=[
{path:'overview',component:DashboardPageComponent,data:{title:'overview',breadcrumb:'overview'},
];
@NGD模块({
导入:[RouterModule.forChild(路由)],
导出:[路由模块]
})
导出类DashboardRoutingModule{}
@组成部分({
选择器:“应用程序标题”,
templateUrl:'./title.component.html',
样式URL:['./title.component.scss']
})
导出类TitleComponent实现OnInit、OnDestroy{
私人认购:认购;
公开名称:String=“”;
建造商(
专用路由器:路由器,
私有激活路由:激活路由
) {
this.title=this.translate(this.buildTitle(this.activatedRoute.firstChild));
}
恩戈尼尼特(){
this.subscription=this.router.events.pipe(
过滤器(事件=>NavigationEnd的事件实例),
distinctUntilChanged(),
).订阅(()=>{
this.title=this.buildTitle(this.activatedRoute.firstChild);
});
}
恩贡德斯特罗(){
如果(此订阅){
this.subscription.unsubscripte();
}
}
buildTitle(路由:ActivatedRoute):字符串{
返回route.routeConfig&&route.routeConfig.data?route.routeConfig.data.title:“”;
}
翻译(标题:String):String{
如果(!title | | title=='')返回title;
控制台日志(标题);
开关(标题){
案例“概述”:返回$localize`:@@Overview:Overview`;
//其他情况。。。
}
}
}
但是在本例中,$localize
:@@overview:overview
始终显示“overview”,但不显示messages.es.xlf翻译。
你知道如何使用$localize来翻译这个标题吗?

我们遇到了同样的问题。angular不会拾取路由器中设置的任何$localize字符串进行转换(尽管它们是通过CLI提取的)。