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