一、安装
ngx-translate官网地址http://www.ngx-translate.com/ github地址https://github.com/ngx-translate/core
我们在应用中会使用到如下两个模块
- 1 安装
npm install @ngx-translate/core@10.0.0 --save
一定要注意版本问题:
npm install @ngx-translate/http-loader@3.0.0 --save
二、使用
看两个例子你就明白了!
https://stackblitz.com/github/ngx-translate/example?file=src%2Fapp%2Fapp.module.ts
https://github.com/ngx-translate
需要注意的是,如果你有很多子模块,一定要把TranslateModule 导入到要使用的各个子模块中去,而不是只在appmodule里导入。文档中有提及,注意看这里 https://github.com/ngx-translate/core
https://stackoverflow.com/questions/40538550/angular-2-0-translate-pipe-could-not-be-found 也可以看这里
三、用法
三种方式:Use the service, the pipe or the directive:
看文档 https://github.com/ngx-translate/core