angular8.0學習筆記之語言國際化


1.首先安裝ngx-translate依賴

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

2.在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.在需要語言國際化的組件中引入translateService;

4.在assets目錄下新建lang文件夾存放自己需要國家的json;

 

5.在組件模板中.app.component.html中使用

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM