From 032b03ec15ad1d69a097c9bc399f9d9480ed2573 Mon Sep 17 00:00:00 2001 From: Anurag Awasthi Date: Mon, 2 Sep 2019 01:15:48 +0530 Subject: [PATCH] Added some fixes and made language change not reload (#31) * Added some fixes and made language change not reload * Remove unwanted code Signed-off-by: Rohit Yadav --- ui/src/components/CloudMonkey/Resource.vue | 10 +++++----- ui/src/components/layouts/PageView.vue | 4 ++-- ui/src/components/menu/menu.js | 2 +- ui/src/components/tools/Breadcrumb.vue | 4 ++-- ui/src/components/tools/TranslationMenu.vue | 15 ++++++--------- ui/src/locales/ar.json | 2 +- ui/src/locales/ca.json | 2 +- ui/src/locales/en.json | 2 +- ui/src/locales/it_IT.json | 2 +- ui/src/locales/ko_KR.json | 2 +- ui/src/locales/nb_NO.json | 2 +- ui/src/locales/pl.json | 2 +- ui/src/locales/ru_RU.json | 2 +- 13 files changed, 24 insertions(+), 27 deletions(-) diff --git a/ui/src/components/CloudMonkey/Resource.vue b/ui/src/components/CloudMonkey/Resource.vue index 7883ce310c6..c976a4d0806 100644 --- a/ui/src/components/CloudMonkey/Resource.vue +++ b/ui/src/components/CloudMonkey/Resource.vue @@ -279,6 +279,11 @@ export default { if (to.fullPath !== from.fullPath) { this.fetchData() } + }, + '$i18n.locale' (to, from) { + if (to !== from) { + this.fetchData() + } } }, beforeCreate () { @@ -289,9 +294,6 @@ export default { this.breadList = [] this.name = this.$route.name this.$route.matched.forEach((item) => { - if (item.meta.title) { - item.meta.title = this.$t(item.meta.title) - } this.breadList.push(item) }) }, @@ -319,8 +321,6 @@ export default { } else { this.dataView = false } - console.log(this.$route) - console.log(this.routeName) if (this.$route && this.$route.meta && this.$route.meta.permission) { this.apiName = this.$route.meta.permission[0] if (this.$route.meta.columns) { diff --git a/ui/src/components/layouts/PageView.vue b/ui/src/components/layouts/PageView.vue index 6055a7aeb3d..e49b967f70b 100644 --- a/ui/src/components/layouts/PageView.vue +++ b/ui/src/components/layouts/PageView.vue @@ -2,7 +2,7 @@
@@ -71,7 +71,7 @@ export default { }, getPageMeta () { // eslint-disable-next-line - this.pageTitle = (typeof(this.title) === 'string' || !this.title) ? this.title : this.$route.meta.title + this.pageTitle = (typeof(this.title) === 'string' || !this.title) ? this.$t(this.title) : this.$t(this.$route.meta.title) const content = this.$refs.content if (content) { diff --git a/ui/src/components/menu/menu.js b/ui/src/components/menu/menu.js index e769539268a..5a4fdc57fad 100644 --- a/ui/src/components/menu/menu.js +++ b/ui/src/components/menu/menu.js @@ -121,7 +121,7 @@ export default { {this.renderIcon(menu.meta.icon)} - {menu.meta.title} + {this.$t(menu.meta.title)} {itemArr} diff --git a/ui/src/components/tools/Breadcrumb.vue b/ui/src/components/tools/Breadcrumb.vue index 1af3d753755..fdcf1c13508 100644 --- a/ui/src/components/tools/Breadcrumb.vue +++ b/ui/src/components/tools/Breadcrumb.vue @@ -2,9 +2,9 @@ - {{ item.meta.title }} + {{ this.$t(item.meta.title) }} - {{ item.meta.title }} + {{ this.$t(item.meta.title) }} diff --git a/ui/src/components/tools/TranslationMenu.vue b/ui/src/components/tools/TranslationMenu.vue index 041fc07f3a5..f380c447085 100644 --- a/ui/src/components/tools/TranslationMenu.vue +++ b/ui/src/components/tools/TranslationMenu.vue @@ -59,7 +59,6 @@ export default { }, data () { return { - locale: null, enUS, arEG, caES, @@ -81,16 +80,14 @@ export default { methods: { moment, onClick (e) { - const localeValue = e.key - this.locale = localeValue + var localeValue = e.key if (!localeValue) { - moment.locale('en') - } else { - moment.locale(localeValue) - this.$i18n.locale = e.key - Vue.ls.set('current_locale', e.key) - this.$router.go(0) + localeValue = 'en' } + this.$locale = localeValue + moment.locale(localeValue) + this.$i18n.locale = localeValue + Vue.ls.set('current_locale', localeValue) } } } diff --git a/ui/src/locales/ar.json b/ui/src/locales/ar.json index b66f1d694cb..cb98325b77b 100644 --- a/ui/src/locales/ar.json +++ b/ui/src/locales/ar.json @@ -185,7 +185,7 @@ "esplifetime": "\u0639\u0645\u0631 ESP (\u062b\u0627\u0646\u064a\u0629)", "esppolicy": "\u0633\u064a\u0627\u0633\u0629 ESP", "expunge": "Expunge", - "fingerprint": "FingerPrint", + "fingerprint": "Finger Print", "firstname": "First Name", "forced": "Force Stop", "forceencap": "Force UDP Encapsulation of ESP Packets", diff --git a/ui/src/locales/ca.json b/ui/src/locales/ca.json index 9073cdb0ff3..bf7045c1478 100644 --- a/ui/src/locales/ca.json +++ b/ui/src/locales/ca.json @@ -185,7 +185,7 @@ "esplifetime": "ESP Lifetime (second)", "esppolicy": "ESP policy", "expunge": "Expunge", - "fingerprint": "FingerPrint", + "fingerprint": "Finger Print", "firstname": "First Name", "forced": "Force Stop", "forceencap": "Force UDP Encapsulation of ESP Packets", diff --git a/ui/src/locales/en.json b/ui/src/locales/en.json index 2177f6520af..b385979b6e9 100644 --- a/ui/src/locales/en.json +++ b/ui/src/locales/en.json @@ -194,7 +194,7 @@ "expunge": "Expunge", "externalId": "External Id", "extra": "Extra Arguments", - "fingerprint": "FingerPrint", + "fingerprint": "Finger Print", "firstname": "First Name", "forced": "Force Stop", "forceencap": "Force UDP Encapsulation of ESP Packets", diff --git a/ui/src/locales/it_IT.json b/ui/src/locales/it_IT.json index 940154fa10e..73c9123e748 100644 --- a/ui/src/locales/it_IT.json +++ b/ui/src/locales/it_IT.json @@ -185,7 +185,7 @@ "esplifetime": "ESP Lifetime (second)", "esppolicy": "Policy di ESP", "expunge": "Expunge", - "fingerprint": "FingerPrint", + "fingerprint": "Finger Print", "firstname": "Nome", "forced": "Forza l'Arresto", "forceencap": "Force UDP Encapsulation of ESP Packets", diff --git a/ui/src/locales/ko_KR.json b/ui/src/locales/ko_KR.json index db191b60b14..4b574342fed 100644 --- a/ui/src/locales/ko_KR.json +++ b/ui/src/locales/ko_KR.json @@ -185,7 +185,7 @@ "esplifetime": "ESP \uc720\ud6a8\uae30\uac04(\ucd08)", "esppolicy": "ESP \uc815\ucc45", "expunge": "Expunge", - "fingerprint": "FingerPrint", + "fingerprint": "Finger Print", "firstname": "\uc774\ub984", "forced": "\uac15\uc81c \uc815\uc9c0", "forceencap": "Force UDP Encapsulation of ESP Packets", diff --git a/ui/src/locales/nb_NO.json b/ui/src/locales/nb_NO.json index 5f86ee36f45..f656060c2c4 100644 --- a/ui/src/locales/nb_NO.json +++ b/ui/src/locales/nb_NO.json @@ -185,7 +185,7 @@ "esplifetime": "ESP levetid (sekund)", "esppolicy": "ESP policy", "expunge": "Permanent Slett", - "fingerprint": "Fingeravtrykk", + "fingerprint": "Finger avtrykk", "firstname": "Fornavn", "forced": "Tving stopp", "forceencap": "Tving UDP innkapsling av ESP-pakker", diff --git a/ui/src/locales/pl.json b/ui/src/locales/pl.json index d81a7be412b..ee30b562c80 100644 --- a/ui/src/locales/pl.json +++ b/ui/src/locales/pl.json @@ -185,7 +185,7 @@ "esplifetime": "ESP Lifetime (second)", "esppolicy": "ESP policy", "expunge": "Expunge", - "fingerprint": "FingerPrint", + "fingerprint": "Finger Print", "firstname": "Pierwsza nazwa", "forced": "Force Stop", "forceencap": "Force UDP Encapsulation of ESP Packets", diff --git a/ui/src/locales/ru_RU.json b/ui/src/locales/ru_RU.json index 042a5c43727..13656fc88f1 100644 --- a/ui/src/locales/ru_RU.json +++ b/ui/src/locales/ru_RU.json @@ -185,7 +185,7 @@ "esplifetime": "\u0412\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 ESP (\u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445)", "esppolicy": "\u041f\u043e\u043b\u0438\u0442\u0438\u043a\u0430 ESP", "expunge": "\u0423\u0434\u0430\u043b\u0451\u043d", - "fingerprint": "FingerPrint", + "fingerprint": "Finger Print", "firstname": "\u0418\u043c\u044f", "forced": "\u041f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c", "forceencap": "Force UDP Encapsulation of ESP Packets",