This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-rocketbot-ui.git
The following commit(s) were added to refs/heads/master by this push:
new a9ee001 Fix bug: language initialization failed (#171)
a9ee001 is described below
commit a9ee0012264e3c47b2e004b8d2600f8cd0e403e0
Author: Allen Wang <[email protected]>
AuthorDate: Tue Oct 29 16:01:26 2019 +0800
Fix bug: language initialization failed (#171)
---
src/main.ts | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/main.ts b/src/main.ts
index c11c4d3..db06627 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -46,16 +46,15 @@ Vue.directive('clickout', clickout);
Vue.directive('tooltip', tooltip);
Vue.filter('dateformat', (dataStr: any, pattern: string = 'YYYY-MM-DD
HH:mm:ss') => moment(dataStr).format(pattern));
-const saveLang = window.localStorage.getItem('lang');
-let language = navigator.language;
-if (!saveLang) {
- window.localStorage.setItem('lang', language.split('-')[0]);
-} else {
- language = saveLang;
+
+const savedLanguage = window.localStorage.getItem('lang');
+let language = navigator.language.split('-')[0];
+if (!savedLanguage) {
+ window.localStorage.setItem('lang', language);
}
+language = savedLanguage ? savedLanguage : language;
const i18n = new VueI18n({
- // locale: 'en-us',
locale: language,
messages: {
zh,