【发布时间】:2019-10-02 02:45:49
【问题描述】:
我目前在angular 7上使用ngx-translate。我的项目正在翻译两种语言,英文和中文,该项目由如下所示的结构组成,A.component是父组件,B.component是子组件。
模块 A
{
componentB:{
B.component.ts
....
},
A.component.ts
A.module.ts
....
}
导出类 BComponent 实现 OnInit{
constructor(private translate: TranslateService
) {
translate.addLangs(['zh-CN', 'en']);
translate.use('zh-CN');
}
}
上面的代码正在翻译。
但是如果上面的代码只添加到A.component而不是B.component。翻译不会发生在 B.component 上。
不知道有没有办法将代码添加到模块的父组件中,并且以下所有子组件都可以自动翻译,而无需将代码放在每个子组件中。
【问题讨论】:
-
您找到解决方案了吗? @user824624
标签: angular ngx-translate