mirror of
https://github.com/goharbor/harbor.git
synced 2024-10-03 07:47:54 +02:00
Improve i18n service (#15215)
Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
parent
f902db9d85
commit
91f4d412f0
@ -73,16 +73,6 @@ export class AppComponent {
|
||||
});
|
||||
}
|
||||
initLanguage() {
|
||||
/**
|
||||
* due to the bug(https://github.com/ngx-translate/core/issues/1258) of translate module
|
||||
* we have to call use method for all supported languages
|
||||
* use method will load related language json from backend server
|
||||
*/
|
||||
const usedLangs: Array<Observable<any>> = [];
|
||||
supportedLangs.forEach(lang => {
|
||||
usedLangs.push(this.translate.use(lang));
|
||||
});
|
||||
forkJoin(usedLangs).subscribe(() => { // use target lang after all langs json loaded
|
||||
this.translate.addLangs(supportedLangs);
|
||||
this.translate.setDefaultLang(DeFaultLang);
|
||||
let selectedLang: string = DeFaultLang;
|
||||
@ -101,8 +91,7 @@ export class AppComponent {
|
||||
}
|
||||
}
|
||||
localStorage.setItem(DEFAULT_LANG_LOCALSTORAGE_KEY, selectedLang);
|
||||
// use method will load related language json from backend server
|
||||
this.translate.use(selectedLang);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,9 @@ export class NavigatorComponent implements OnInit {
|
||||
switchLanguage(lang: string): void {
|
||||
this.selectedLang = lang;
|
||||
localStorage.setItem(DEFAULT_LANG_LOCALSTORAGE_KEY, lang);
|
||||
this.translate.use(lang);
|
||||
// due to the bug(https://github.com/ngx-translate/core/issues/1258) of translate module
|
||||
// have to reload
|
||||
this.translate.use(lang).subscribe(() => window.location.reload());
|
||||
}
|
||||
|
||||
// Handle the home action
|
||||
|
Loading…
Reference in New Issue
Block a user