如何详细配置Angular多语言支持?
- 内容介绍
- 文章标签
- 相关推荐
本文共计227个文字,预计阅读时间需要1分钟。
Angular 国际化方案,采用 ngx-translate 实现。
安装模块:bashnpm install @ngx-translate/core --save
在根模块中导入:javascript// other moduleimport { TranslateModule } from '@ngx-translate/core';
@NgModule({ declarations: [ 'AppComponent' ]})export class AppModule { }
angular的国际化方案,采用ngx-translate来实现。
安装模块:
npm install @ngx-translate/core --save
在根模块中导入:
// other module import {TranslateModule} from '@ngx-translate/core'; @NgModule({ declarations: [ AppComponent, ], imports: [ // other module TranslateModule.forRoot(), ], providers: [ ], bootstrap: [AppComponent] }) export class AppModule { }
我们希望可以在一个固定的文件里面配置对应的翻译文件,然后在每个用到的组件里面使用它,随意我们需要借助TranslateHttpLoader来加载翻译文件。首先安装TranslateHttpLoader:
npm install @ngx-translate/www.npmjs.com/package/@ngx-translate/core
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持自由互联。
本文共计227个文字,预计阅读时间需要1分钟。
Angular 国际化方案,采用 ngx-translate 实现。
安装模块:bashnpm install @ngx-translate/core --save
在根模块中导入:javascript// other moduleimport { TranslateModule } from '@ngx-translate/core';
@NgModule({ declarations: [ 'AppComponent' ]})export class AppModule { }
angular的国际化方案,采用ngx-translate来实现。
安装模块:
npm install @ngx-translate/core --save
在根模块中导入:
// other module import {TranslateModule} from '@ngx-translate/core'; @NgModule({ declarations: [ AppComponent, ], imports: [ // other module TranslateModule.forRoot(), ], providers: [ ], bootstrap: [AppComponent] }) export class AppModule { }
我们希望可以在一个固定的文件里面配置对应的翻译文件,然后在每个用到的组件里面使用它,随意我们需要借助TranslateHttpLoader来加载翻译文件。首先安装TranslateHttpLoader:
npm install @ngx-translate/www.npmjs.com/package/@ngx-translate/core
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持自由互联。

