I used ng2-translate
to translate headings and texts in my angular2
web app.
But I am now confused when I trying to translate texts that pass from .ts
file.
for example, I can translate texts in html file as following.
<ion-row id="login-row">
<ion-col>
<ion-list>
<ion-item>
<ion-label stacked>{{ 'USERNAME' | translate }}</ion-label>
<ion-input type="text" [(ngModel)]="username"></ion-input>
</ion-item>
<ion-item>
<ion-label stacked>{{ 'PASSWORD' | translate }}</ion-label>
<ion-input type="password" [(ngModel)]="password"></ion-input>
</ion-item>
</ion-list>
</ion-col>
</ion-row>
But if I have .ts
file text as following. Then How I can translate those texts.
doCheckbox() {
let alert = this.alertCtrl.create();
alert.setTitle('Please Select a Location');
alert.addInput({
type: 'radio',
label: 'Option 1',
value: 'opt1',
checked: true
});
alert.addInput({
type: 'radio',
label: 'Option 2',
value: 'opt2'
});
alert.addButton({
text: 'OK',
handler: data => {
this.testRadioOpen = false;
this.testRadioResult = data;
}
});
alert.present();
}
in above example, I want to translate texts like
'Please Select a Location', 'Option 1','Option 2', 'OK'...
If anyone has an idea to overcome this problem, help me. Thanks.