Skip to content

Commit

Permalink
[web-app] enable app default lang to en (#337)
Browse files Browse the repository at this point in the history
  [web-app] enable app default lang to en

  [web-app] fix eslint warning
  • Loading branch information
tomsun28 committed Oct 9, 2022
1 parent a167b5b commit 32ffbe3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
18 changes: 11 additions & 7 deletions web-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, ElementRef, OnInit, Renderer2 } from '@angular/core';
import { Component, ElementRef, Inject, OnInit, Renderer2 } from '@angular/core';
import { NavigationEnd, NavigationError, RouteConfigLoadStart, Router } from '@angular/router';
import { TitleService, VERSION as VERSION_ALAIN } from '@delon/theme';
import { I18NService } from '@core';
import { ALAIN_I18N_TOKEN, TitleService, VERSION as VERSION_ALAIN } from '@delon/theme';
import { environment } from '@env/environment';
import { NzModalService } from 'ng-zorro-antd/modal';
import { VERSION as VERSION_ZORRO } from 'ng-zorro-antd/version';
Expand All @@ -15,7 +16,8 @@ export class AppComponent implements OnInit {
renderer: Renderer2,
private router: Router,
private titleSrv: TitleService,
private modalSrv: NzModalService
private modalSrv: NzModalService,
@Inject(ALAIN_I18N_TOKEN) private i18nSvc: I18NService
) {
renderer.setAttribute(el.nativeElement, 'ng-alain-version', VERSION_ALAIN.full);
renderer.setAttribute(el.nativeElement, 'ng-zorro-version', VERSION_ZORRO.full);
Expand All @@ -29,11 +31,13 @@ export class AppComponent implements OnInit {
}
if (configLoad && ev instanceof NavigationError) {
this.modalSrv.confirm({
nzTitle: `提醒`,
nzContent: environment.production ? `应用可能已发布新版本,请点击刷新才能生效。` : `无法加载路由:${ev.url}`,
nzTitle: this.i18nSvc.fanyi('common.notice'),
nzContent: environment.production
? `New version may have been published, please click refresh.`
: `Can not resolve route:${ev.url}`,
nzCancelDisabled: false,
nzOkText: '刷新',
nzCancelText: '忽略',
nzOkText: this.i18nSvc.fanyi('common.refresh'),
nzCancelText: this.i18nSvc.fanyi('common.ignore'),
nzOnOk: () => location.reload()
});
}
Expand Down
2 changes: 1 addition & 1 deletion web-app/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { DELON_LOCALE, en_US as delonLang } from '@delon/theme';
import { enUS as dateLang } from 'date-fns/locale';
import { NZ_DATE_LOCALE, NZ_I18N, en_US as zorroLang } from 'ng-zorro-antd/i18n';
const LANG = {
abbr: 'en',
abbr: 'en-US',
ng: ngLang,
zorro: zorroLang,
date: dateLang,
Expand Down
2 changes: 1 addition & 1 deletion web-app/src/app/core/i18n/i18n.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface LangConfigData {
delon: NzSafeAny;
}

const DEFAULT = 'zh-CN';
const DEFAULT = 'en-US';
const LANGS: { [key: string]: LangConfigData } = {
'en-US': {
text: 'English',
Expand Down
2 changes: 2 additions & 0 deletions web-app/src/assets/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@
"common.value": "Value",
"common.search": "Search",
"common.refresh": "Refresh",
"common.notice": "Notice",
"common.ignore": "Ignore",
"common.edit-time": "Last Update Time",
"common.new-time": "Create Time",
"common.edit": "Operate",
Expand Down
2 changes: 2 additions & 0 deletions web-app/src/assets/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@
"common.value": "",
"common.search": "搜索",
"common.refresh": "刷新",
"common.notice": "提醒",
"common.ignore": "忽略",
"common.edit-time": "更新时间",
"common.new-time": "创建时间",
"common.edit": "操作",
Expand Down
2 changes: 2 additions & 0 deletions web-app/src/assets/i18n/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@
"common.value": "",
"common.search": "搜索",
"common.refresh": "刷新",
"common.notice": "提醒",
"common.ignore": "忽略",
"common.edit-time": "更新時間",
"common.new-time": "創建時間",
"common.edit": "操作",
Expand Down

0 comments on commit 32ffbe3

Please sign in to comment.