Home > Software design >  Translate the menu bar component of PrimeNG
Translate the menu bar component of PrimeNG

Time:10-19

I want to translate primeNG menu bar component. But I don't know how to handle the translation inside of .ts file. I want to get translate data from the .json file.

this.items = [
      { label: 'Project Management', icon: 'pi pi-chart-line'},
      { label: 'Item list', icon: 'pi pi-book'},
      { label: 'Item analysis', icon: 'pi pi-list'}
    ];

Upper you can see my menu bar items. I want to change the label name when I change the language from the language change dropdown.

here is the en.json file

{
    
"menu" : {
        "pManagement" : "Project Management",
        "iList" : "Item list",
        "iAnalysis" : "Item analysis"
    }
}

CodePudding user response:

You'll need to use NGX-Translate internationalization library for Angular. Learn more about it here.

  • Related