Merge pull request #1859 from wknet123/dev-revised

Lowercase language names.
This commit is contained in:
Steven Zou 2017-03-29 20:00:19 +08:00 committed by GitHub
commit 8ecfb04d1a
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,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));

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