Hi,
I’m using ngx-translate for the translation of my app. Here is the docu of it: https://ionicframework.com/docs/resources/ng2-translate/
In my opinion it is not so nice to use. In HTML it is ok but if you want to use it in TS it is much stuff. If you want to use it for example for an Alert, you have to do something like this:
translate.get(['noButton', 'yesButton']).subscribe(
buttons => {
let buttons = [
{
text: buttons.noButton,
role: "cancel"
},
{
text: buttons.yesButton,
handler: () => {
// do something
}
}
];
}
);
translate.get(['alertTitle', 'alertSubTitle']).subscribe(
alert => {
let alertMsg = this.alertCtrl.create({
title: alert.alertTitle,
subTitle: alert.alertSubTitle,
buttons: buttons
});
alert.present();
}
);
And that for every translation… Isn’t there a better way? For example to do it with one line for the translation like this:
...
let buttons = [
{
text: translation.get('noButton'),
role: "cancel"
},
{
text: translation.get('yesButton'),
handler: () => {
// do something
}
}
];
...