For the translation of headings and texts in my Angular2 web application, I utilized ng2-translate. However, I am facing a dilemma when it comes to translating texts that are passed from a .ts file.
For example, I can easily translate texts in an HTML file as shown below.
<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>
However, if I have text in a .ts file like the following, then how can I go about translating 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 the above example, I aim to translate texts such as
'Please Select a Location', 'Option 1','Option 2', 'OK'...
If anyone has a solution to solve this issue, please assist me. Thank you.