我想在侧菜单标题中使用翻译,我读过本教程 https://ionicthemes.com/tutorials/about/internationalize-and-localize-your-ionic2-app-with-ngtranslate我将其解决为:
translate.get('HOME').subscribe(res => {
this.pages= [
{title: res , component: HomePage},
{title: 'My Account', component: MyAccountPage},
{title: 'Changer Pass' , component: ChangePasswordPage}
]
它有效,但问题是我不想从翻译文件中获取很多标题来将它们设置为侧菜单标题。
请不要使用forkJoin
在这种情况下,操作员。 ngx-translate 支持通过将键数组传递给一次来获取多个翻译get()
像这样的方法:
translate.get(['HOME', 'MY_ACCOUNT', 'CHANGE_PASSWORD']).subscribe(translations => {
this.pages= [
{ title: translations.HOME, component: HomePage},
{ title: translations.MY_ACCOUNT, component: MyAccountPage},
{ title: translations.CHANGE_PASSWORD, component: ChangePasswordPage}
];
})
Edit:
Here https://github.com/ngx-translate/core#methods您可以找到所有支持的方法及其签名。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)