diff options
author | Yoshie Muranaka <yoshiemuranaka@gmail.com> | 2020-09-09 20:08:14 +0300 |
---|---|---|
committer | Yoshie Muranaka <yoshiemuranaka@gmail.com> | 2020-09-25 06:27:10 +0300 |
commit | f15cc7ac46022487ca36a3d8a66eb86791e040f9 (patch) | |
tree | 97815d7c99eb1facaf6ae2b5134833bca42ad007 | |
parent | 12bc875329c0d8a9a28aa51daa6adfecb834f6f9 (diff) | |
download | webui-vue-f15cc7ac46022487ca36a3d8a66eb86791e040f9.tar.xz |
Move translation into routes file
- Added intial application load document title update with
created hook
Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Change-Id: I73d18ed4a56bd04601fa7382c2d6c2ec504b03f5
-rw-r--r-- | src/App.vue | 5 | ||||
-rw-r--r-- | src/components/Global/PageTitle.vue | 2 | ||||
-rw-r--r-- | src/router/routes.js | 51 |
3 files changed, 30 insertions, 28 deletions
diff --git a/src/App.vue b/src/App.vue index 30de752b..b57a91db 100644 --- a/src/App.vue +++ b/src/App.vue @@ -13,8 +13,11 @@ export default { name: 'App', watch: { $route: function(to) { - document.title = this.$t(to.meta.title) || 'Page is missing title'; + document.title = to.meta.title || 'Page is missing title'; } + }, + created() { + document.title = this.$route.meta.title || 'Page is missing title'; } }; </script> diff --git a/src/components/Global/PageTitle.vue b/src/components/Global/PageTitle.vue index a77e0a07..e3dc8d0c 100644 --- a/src/components/Global/PageTitle.vue +++ b/src/components/Global/PageTitle.vue @@ -16,7 +16,7 @@ export default { }, data() { return { - title: this.$t(this.$route.meta.title) + title: this.$route.meta.title }; } }; diff --git a/src/router/routes.js b/src/router/routes.js index d187713a..1a86510c 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -25,9 +25,8 @@ import ServerPowerOperations from '@/views/Control/ServerPowerOperations'; import SslCertificates from '@/views/AccessControl/SslCertificates'; import Unauthorized from '@/views/Unauthorized'; import VirtualMedia from '@/views/Control/VirtualMedia'; +import i18n from '@/i18n'; -// Meta title is translated using i18n in App.vue and PageTitle.Vue -// Example meta: {title: 'appPageTitle.overview'} const routes = [ { path: '/login', @@ -38,7 +37,7 @@ const routes = [ name: 'login', component: Login, meta: { - title: 'appPageTitle.login' + title: i18n.t('appPageTitle.login') } }, { @@ -46,7 +45,7 @@ const routes = [ name: 'change-password', component: ChangePassword, meta: { - title: 'appPageTitle.changePassword', + title: i18n.t('appPageTitle.changePassword'), requiresAuth: true } } @@ -64,7 +63,7 @@ const routes = [ name: 'serial-over-lan-console', component: SerialOverLanConsole, meta: { - title: 'appPageTitle.serialOverLan' + title: i18n.t('appPageTitle.serialOverLan') } }, { @@ -72,7 +71,7 @@ const routes = [ name: 'kvm-console', component: KvmConsole, meta: { - title: 'appPageTitle.kvm' + title: i18n.t('appPageTitle.kvm') } } ] @@ -89,7 +88,7 @@ const routes = [ name: 'overview', component: Overview, meta: { - title: 'appPageTitle.overview' + title: i18n.t('appPageTitle.overview') } }, { @@ -97,7 +96,7 @@ const routes = [ name: 'profile-settings', component: ProfileSettings, meta: { - title: 'appPageTitle.profileSettings' + title: i18n.t('appPageTitle.profileSettings') } }, { @@ -105,7 +104,7 @@ const routes = [ name: 'event-logs', component: EventLogs, meta: { - title: 'appPageTitle.eventLogs' + title: i18n.t('appPageTitle.eventLogs') } }, { @@ -113,7 +112,7 @@ const routes = [ name: 'hardware-status', component: HardwareStatus, meta: { - title: 'appPageTitle.hardwareStatus' + title: i18n.t('appPageTitle.hardwareStatus') } }, { @@ -121,7 +120,7 @@ const routes = [ name: 'sensors', component: Sensors, meta: { - title: 'appPageTitle.sensors' + title: i18n.t('appPageTitle.sensors') } }, { @@ -129,7 +128,7 @@ const routes = [ name: 'ldap', component: Ldap, meta: { - title: 'appPageTitle.ldap' + title: i18n.t('appPageTitle.ldap') } }, { @@ -137,7 +136,7 @@ const routes = [ name: 'local-users', component: LocalUserManagement, meta: { - title: 'appPageTitle.localUserManagement' + title: i18n.t('appPageTitle.localUserManagement') } }, { @@ -145,7 +144,7 @@ const routes = [ name: 'ssl-certificates', component: SslCertificates, meta: { - title: 'appPageTitle.sslCertificates' + title: i18n.t('appPageTitle.sslCertificates') } }, { @@ -153,7 +152,7 @@ const routes = [ name: 'date-time-settings', component: DateTimeSettings, meta: { - title: 'appPageTitle.dateTimeSettings' + title: i18n.t('appPageTitle.dateTimeSettings') } }, { @@ -161,7 +160,7 @@ const routes = [ name: 'firmware', component: Firmware, meta: { - title: 'appPageTitle.firmware' + title: i18n.t('appPageTitle.firmware') } }, { @@ -169,7 +168,7 @@ const routes = [ name: 'kvm', component: Kvm, meta: { - title: 'appPageTitle.kvm' + title: i18n.t('appPageTitle.kvm') } }, { @@ -177,7 +176,7 @@ const routes = [ name: 'manage-power-usage', component: ManagePowerUsage, meta: { - title: 'appPageTitle.managePowerUsage' + title: i18n.t('appPageTitle.managePowerUsage') } }, { @@ -185,7 +184,7 @@ const routes = [ name: 'network-settings', component: NetworkSettings, meta: { - title: 'appPageTitle.networkSettings' + title: i18n.t('appPageTitle.networkSettings') } }, { @@ -193,7 +192,7 @@ const routes = [ name: 'reboot-bmc', component: RebootBmc, meta: { - title: 'appPageTitle.rebootBmc' + title: i18n.t('appPageTitle.rebootBmc') } }, { @@ -201,7 +200,7 @@ const routes = [ name: 'server-led', component: ServerLed, meta: { - title: 'appPageTitle.serverLed' + title: i18n.t('appPageTitle.serverLed') } }, { @@ -209,7 +208,7 @@ const routes = [ name: 'serial-over-lan', component: SerialOverLan, meta: { - title: 'appPageTitle.serialOverLan' + title: i18n.t('appPageTitle.serialOverLan') } }, { @@ -217,7 +216,7 @@ const routes = [ name: 'server-power-operations', component: ServerPowerOperations, meta: { - title: 'appPageTitle.serverPowerOperations' + title: i18n.t('appPageTitle.serverPowerOperations') } }, { @@ -225,7 +224,7 @@ const routes = [ name: 'virtual-media', component: VirtualMedia, meta: { - title: 'appPageTitle.virtualMedia' + title: i18n.t('appPageTitle.virtualMedia') } }, { @@ -233,7 +232,7 @@ const routes = [ name: 'unauthorized', component: Unauthorized, meta: { - title: 'appPageTitle.unauthorized' + title: i18n.t('appPageTitle.unauthorized') } }, { @@ -241,7 +240,7 @@ const routes = [ name: 'page-not-found', component: PageNotFound, meta: { - title: 'appPageTitle.pageNotFound' + title: i18n.t('appPageTitle.pageNotFound') } } ] |