angular8.0 study notes the language internationalization

1. First mounting ngx-translate dependent

npm install @ngx-translate/core --save
npm install @ngx-translate/http-loader --save

2. incorporated in app.module.ts

import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
export function createTranslateLoader(http: HttpClient) {
  return new TranslateHttpLoader(http, '../assets/lang/', '.json');
}

3. The introduction of translateService in need of international language components;

4. New lang file in the assets directory folder to store their needs json country;

 

5. In the assembly template .app.component.html

 

Guess you like

Origin www.cnblogs.com/huangmin1992/p/10959414.html