Angular translate variable replacement Angular translate variable replacement angularjs angularjs

Angular translate variable replacement


Here the answer to do it directly in the HTML template :

{{ 'user.autocomplete.no_user' | translate:{ username: user.searchUser } }}


You can create an object containing all your translation parameters and use it for the translation like this :

{{ 'user.autocomplete.no_user' | translate:translationParameters }}

Look at this plunker how I did it, for more details it's explain at the end of the section Variable replacement in translate filter of Angular Translate doc


This is how you can do it in Angular 5+

translation file:

{  "HELLO": "Hello {user}"}

Template:

{ 'HELLO' | translate: { user: "World" } }

Displays: Hello World