微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

angular中的两种翻译

1.就是{{'Save'|translate}} 就是在要翻译的后面直接加上translate
2.对于弹出框...来说的 this.translateService.get().subscribe(....
① this.translateService.get(['This_Field_Is_Not_Less_Than','Characters']).subscribe(res=>{
minlengthMessageStr= res['This_Field_Is_Not_Less_Than']+this.question.optionList[0].minText+ res['Characters']
});


② this.translateService.get(["Close",message]).subscribe(async translated => {
const alert = await this.alertController.create({
header: '',
message: translated[message],
buttons: [
{
text: translated['Close'],
role: 'cancel',
cssClass: 'secondary',
handler: (blah) => {
console.log('Confirm Cancel: blah');
}
}
]
});

③ this.translateService.get(["Please_Wait"]).subscribe(async translated => {
this.loading = await this.loadingController.create({
message: translated['Please_Wait'],
showBackdrop: true,
translucent: true,
spinner: 'bubbles'
});
return await this.loading.present();

要使用翻译要引入import { TranslateService } from '@ngx-translate/core';
声明 public translateService:TranslateService

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐