Search code examples
angularinternationalizationmultilingual

Internationalization with Angular 4


I need to Add multiple language support for my Angular 4 Application.I need to know the best approach to achieve this.


Solution

  • You can use ngx-translate which is the standard library for internationalization in Angular 2+

    You can import the library and create a set of json files which contains the translations and put it inside the assets folder.

    Then you can refer it in the HTML. say for example.

    en.json has,

    "guest.first-name": "first Name",
    

    where first one is the key and second is the value to be displayed . and you can refer in the html as,

      <input  [label]="'guest.first-name' | translate" type="text" name="form_name" [(ngModel)]="firstName" required="required" ></input>