当前位置: 代码迷 >> 综合 >> angular2+ 国际化
  详细解决方案

angular2+ 国际化

热度:53   发布时间:2023-12-24 14:17:19.0

本实例是利用啦Ng Alain 构造的项目

1:html中

<button nz-button nzType="primary" nzGhost *ngIf="addBtn" (click)="add()"><i class="anticon anticon-plus"></i> <span>{
   {translate('Add')}}</span></button>

2:ts里

import {I18NService} from '@core/i18n/i18n.service';
constructor(public tsServ: I18NService, private api: ConfigService) { }
translate(key) {return this.tsServ.fanyi(key);
}  此处是使用I18NService里的翻译函数

3:en.json &&zh-CN.json(中文简体)

"Add": "Add"
"Add": "添加"