Lowercase language names.

This commit is contained in:
kunw 2017-03-29 19:57:06 +08:00
parent 04f1c8e625
commit ed11d23e40
6 changed files with 12 additions and 9 deletions

View File

@ -15,6 +15,7 @@ export class AppComponent {
private translate: TranslateService,
private cookie: CookieService,
private session: SessionService) {
translate.addLangs(supportedLangs);
translate.setDefaultLang(enLang);
@ -22,7 +23,7 @@ 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;

View File

@ -18,8 +18,8 @@
<clr-icon shape="caret down"></clr-icon>
</button>
<div class="dropdown-menu">
<a href="javascript:void(0)" clrDropdownItem (click)='switchLanguage("en-US")' [class.lang-selected]='matchLang("en")'>English</a>
<a href="javascript:void(0)" clrDropdownItem (click)='switchLanguage("zh-CN")' [class.lang-selected]='matchLang("zh")'>中文简体</a>
<a href="javascript:void(0)" clrDropdownItem (click)='switchLanguage("en-us")' [class.lang-selected]='matchLang("en")'>English</a>
<a href="javascript:void(0)" clrDropdownItem (click)='switchLanguage("zh-cn")' [class.lang-selected]='matchLang("zh")'>中文简体</a>
</div>
</clr-dropdown>
<clr-dropdown [clrMenuPosition]="'bottom-right'" class="dropdown" *ngIf="isSessionValid">

View File

@ -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

View File

@ -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