ionic-frameworktransloco

Ionic 5 action sheet text not accept transloco


I am using action sheet and transloco translate plugin in my ionic 5 angular app.

When I use transloco on text the APP is considering as string.

buttons: [{
    text: "{{'channel.edit' | transloco}}",
    icon: 'create-outline',

enter image description here

So what should be the correct way to pass the translated text?


Solution

  • Use TranslateService to translate any variables alertTitle;

     constructor(translate: TranslateService) {
        translateService.get('channel.edit').subscribe(
          value => {
            this.alertTitle = value;
          }
        )
    

    then

    buttons: [{
        text: this.alertTitle,
        icon: 'create-outline',