Search code examples
angularjsangular-translate

How to add angular translate to angular material tab?


I am currently working on a website which supports two languages. Angular translate is working fine for my whole website, but i can not figure out a way to apply it for md-tab .

<md-tab label="Shops Near by">

In my translateProvider.translations() i have a variable SHOPS_NEAR_BY with its translation to both the languages. In normal conditions i can use something like :

<span translate="SHOPS_NEAR_BY "> 

and translate will change the value when required.

Can someone help me out with how to apply the same for md-tab ?


Solution

  • The following should work:

    <md-tab label="{{'SHOPS_NEAR_BY' | translate}}">
    

    If it still not showing translation then you must be asynchronously loading those. So for that after resolve of $translate.use(/lang) call $translate(). To avoid flashing of translations keys & values you can use translate-cloak directive.

    Plunker Example

    translate-cloak detail Example

    Check this github discussion about similar issue