Hello,
I’m having some issues translating ion-tab title using ng2-translate.
In tabs.html I have one tab defined as:
<ion-tabs>
<ion-tab [root]="tab1" [tabTitle]="title1" tabIcon="person"></ion-tab>
</ion-tabs>
In tab.ts I’m defining the title1 variable with no initial value and I’m getting the actual translation through an observable:
import {Component, OnInit} from "@angular/core";
import {AccountPage} from "../account/account";
import {TranslateService} from "ng2-translate";
@Component({
templateUrl: 'tabs.html'
})
export class TabsPage implements OnInit {
tab1: any = AccountPage;
title1: string;
constructor(private translate: TranslateService) {}
ngOnInit() {
this.translate.get('account').subscribe((res: string) => {
this.title1 = res;
console.log('title1: ',this.title1);
});
}
}
The translation file is en.json:
{
"account": "Account"
}
In the browser console I can see the log line: title1: Account but the title of the tab is not updated.
It only works when I assign some random value to title1:
title1: string = 'anything';
In this case even though title1 is initially 'anything', I can see the expected value (Account) as the tab’s title, after the ng2-translate observable runs.
I’ve also tried the following syntax and it doesn’t work either:
[tabTitle]="'account' | translate"
Any idea why it only works when I define title1 with some random value?
Thanks
