【发布时间】:2020-06-30 00:39:26
【问题描述】:
我想翻译我的打字稿文件中存在的文本,因此每次我想在使用应用程序时更改语言时,文本都应该更改(例如将语言从英语更改为法语)。我尝试了以下代码但没有用
this.translate.get('example').subscribe(res => { this.title = res.title }
我也试过了,效果很好,但是当我从语言更改为另一种语言时,每次我想翻译打字稿文件中的内容时,我不想在不同的组件中添加相同的代码
this.translate.onLangChange.subscribe(() => {
this.translate.get('example').subscribe(res => { this.title = res.title }
});
【问题讨论】:
标签: angular typescript ngx-translate