From ed11d23e40512bd3f8235cb91625eea152ff7c87 Mon Sep 17 00:00:00 2001 From: kunw Date: Wed, 29 Mar 2017 19:57:06 +0800 Subject: [PATCH] Lowercase language names. --- src/ui_ng/src/app/app.component.ts | 5 +++-- src/ui_ng/src/app/base/navigator/navigator.component.html | 4 ++-- src/ui_ng/src/app/base/navigator/navigator.component.ts | 4 +++- src/ui_ng/src/app/shared/shared.const.ts | 8 ++++---- .../src/i18n/lang/{en-US-lang.json => en-us-lang.json} | 0 .../src/i18n/lang/{zh-CN-lang.json => zh-cn-lang.json} | 0 6 files changed, 12 insertions(+), 9 deletions(-) rename src/ui_ng/src/i18n/lang/{en-US-lang.json => en-us-lang.json} (100%) rename src/ui_ng/src/i18n/lang/{zh-CN-lang.json => zh-cn-lang.json} (100%) diff --git a/src/ui_ng/src/app/app.component.ts b/src/ui_ng/src/app/app.component.ts index 5273bcb36..917980eca 100644 --- a/src/ui_ng/src/app/app.component.ts +++ b/src/ui_ng/src/app/app.component.ts @@ -15,6 +15,7 @@ export class AppComponent { private translate: TranslateService, private cookie: CookieService, private session: SessionService) { + translate.addLangs(supportedLangs); translate.setDefaultLang(enLang); @@ -22,9 +23,9 @@ export class AppComponent { let langSetting = this.cookie.get("harbor-lang"); if (!langSetting || langSetting.trim() === "") { //Use browser lang - langSetting = translate.getBrowserCultureLang(); + langSetting = translate.getBrowserCultureLang().toLowerCase(); } - + let selectedLang = this.isLangMatch(langSetting, supportedLangs) ? langSetting : enLang; translate.use(selectedLang); //this.session.switchLanguage(selectedLang).catch(error => console.error(error)); diff --git a/src/ui_ng/src/app/base/navigator/navigator.component.html b/src/ui_ng/src/app/base/navigator/navigator.component.html index a83279998..f64098287 100644 --- a/src/ui_ng/src/app/base/navigator/navigator.component.html +++ b/src/ui_ng/src/app/base/navigator/navigator.component.html @@ -18,8 +18,8 @@ diff --git a/src/ui_ng/src/app/base/navigator/navigator.component.ts b/src/ui_ng/src/app/base/navigator/navigator.component.ts index 7f33bebca..ff58b090e 100644 --- a/src/ui_ng/src/app/base/navigator/navigator.component.ts +++ b/src/ui_ng/src/app/base/navigator/navigator.component.ts @@ -135,7 +135,9 @@ export class NavigatorComponent implements OnInit { //TODO: console.error('Language ' + lang.trim() + ' is not suppoted'); } - window.location.reload(); + setTimeout(()=>{ + window.location.reload(); + }, 500); } //Handle the home action diff --git a/src/ui_ng/src/app/shared/shared.const.ts b/src/ui_ng/src/app/shared/shared.const.ts index d058f14e6..8eae58f07 100644 --- a/src/ui_ng/src/app/shared/shared.const.ts +++ b/src/ui_ng/src/app/shared/shared.const.ts @@ -1,8 +1,8 @@ -export const supportedLangs = ['en-US', 'zh-CN']; -export const enLang = "en-US"; +export const supportedLangs = ['en-us', 'zh-cn']; +export const enLang = "en-us"; export const languageNames = { - "en-US": "English", - "zh-CN": "中文简体" + "en-us": "English", + "zh-cn": "中文简体" }; export const enum AlertType { DANGER, WARNING, INFO, SUCCESS diff --git a/src/ui_ng/src/i18n/lang/en-US-lang.json b/src/ui_ng/src/i18n/lang/en-us-lang.json similarity index 100% rename from src/ui_ng/src/i18n/lang/en-US-lang.json rename to src/ui_ng/src/i18n/lang/en-us-lang.json diff --git a/src/ui_ng/src/i18n/lang/zh-CN-lang.json b/src/ui_ng/src/i18n/lang/zh-cn-lang.json similarity index 100% rename from src/ui_ng/src/i18n/lang/zh-CN-lang.json rename to src/ui_ng/src/i18n/lang/zh-cn-lang.json