mirror of
https://github.com/knadh/listmonk.git
synced 2025-01-04 13:20:17 +08:00
Add i18n translation to document titles in the router.
This commit is contained in:
parent
45878db35f
commit
76a86fa34a
2 changed files with 32 additions and 30 deletions
|
@ -19,6 +19,22 @@ Vue.config.productionTip = false;
|
||||||
Vue.prototype.$utils = new Utils(i18n);
|
Vue.prototype.$utils = new Utils(i18n);
|
||||||
Vue.prototype.$api = api;
|
Vue.prototype.$api = api;
|
||||||
|
|
||||||
|
// Setup the router.
|
||||||
|
router.beforeEach((to, from, next) => {
|
||||||
|
if (to.matched.length === 0) {
|
||||||
|
next('/404');
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
router.afterEach((to) => {
|
||||||
|
Vue.nextTick(() => {
|
||||||
|
const t = to.meta.title ? `${i18n.tc(to.meta.title, 0)} /` : '';
|
||||||
|
document.title = `${t} listmonk`;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
router,
|
router,
|
||||||
store,
|
store,
|
||||||
|
|
|
@ -14,97 +14,97 @@ const routes = [
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
name: 'dashboard',
|
name: 'dashboard',
|
||||||
meta: { title: 'Dashboard' },
|
meta: { title: '' },
|
||||||
component: () => import(/* webpackChunkName: "main" */ '../views/Dashboard.vue'),
|
component: () => import(/* webpackChunkName: "main" */ '../views/Dashboard.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/lists',
|
path: '/lists',
|
||||||
name: 'lists',
|
name: 'lists',
|
||||||
meta: { title: 'Lists', group: 'lists' },
|
meta: { title: 'globals.terms.lists', group: 'lists' },
|
||||||
component: () => import(/* webpackChunkName: "main" */ '../views/Lists.vue'),
|
component: () => import(/* webpackChunkName: "main" */ '../views/Lists.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/lists/forms',
|
path: '/lists/forms',
|
||||||
name: 'forms',
|
name: 'forms',
|
||||||
meta: { title: 'Forms', group: 'lists' },
|
meta: { title: 'forms.title', group: 'lists' },
|
||||||
component: () => import(/* webpackChunkName: "main" */ '../views/Forms.vue'),
|
component: () => import(/* webpackChunkName: "main" */ '../views/Forms.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/lists/:id',
|
path: '/lists/:id',
|
||||||
name: 'lists',
|
name: 'lists',
|
||||||
meta: { title: 'Lists', group: 'lists' },
|
meta: { title: 'globals.terms.lists', group: 'lists' },
|
||||||
component: () => import(/* webpackChunkName: "main" */ '../views/Lists.vue'),
|
component: () => import(/* webpackChunkName: "main" */ '../views/Lists.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/subscribers',
|
path: '/subscribers',
|
||||||
name: 'subscribers',
|
name: 'subscribers',
|
||||||
meta: { title: 'Subscribers', group: 'subscribers' },
|
meta: { title: 'globals.terms.subscribers', group: 'subscribers' },
|
||||||
component: () => import(/* webpackChunkName: "main" */ '../views/Subscribers.vue'),
|
component: () => import(/* webpackChunkName: "main" */ '../views/Subscribers.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/subscribers/import',
|
path: '/subscribers/import',
|
||||||
name: 'import',
|
name: 'import',
|
||||||
meta: { title: 'Import subscribers', group: 'subscribers' },
|
meta: { title: 'import.title', group: 'subscribers' },
|
||||||
component: () => import(/* webpackChunkName: "main" */ '../views/Import.vue'),
|
component: () => import(/* webpackChunkName: "main" */ '../views/Import.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/subscribers/bounces',
|
path: '/subscribers/bounces',
|
||||||
name: 'bounces',
|
name: 'bounces',
|
||||||
meta: { title: 'Bounces', group: 'subscribers' },
|
meta: { title: 'globals.terms.bounces', group: 'subscribers' },
|
||||||
component: () => import(/* webpackChunkName: "main" */ '../views/Bounces.vue'),
|
component: () => import(/* webpackChunkName: "main" */ '../views/Bounces.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/subscribers/lists/:listID',
|
path: '/subscribers/lists/:listID',
|
||||||
name: 'subscribers_list',
|
name: 'subscribers_list',
|
||||||
meta: { title: 'Subscribers', group: 'subscribers' },
|
meta: { title: 'globals.terms.subscribers', group: 'subscribers' },
|
||||||
component: () => import(/* webpackChunkName: "main" */ '../views/Subscribers.vue'),
|
component: () => import(/* webpackChunkName: "main" */ '../views/Subscribers.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/subscribers/:id',
|
path: '/subscribers/:id',
|
||||||
name: 'subscriber',
|
name: 'subscriber',
|
||||||
meta: { title: 'Subscribers', group: 'subscribers' },
|
meta: { title: 'globals.terms.subscribers', group: 'subscribers' },
|
||||||
component: () => import(/* webpackChunkName: "main" */ '../views/Subscribers.vue'),
|
component: () => import(/* webpackChunkName: "main" */ '../views/Subscribers.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/campaigns',
|
path: '/campaigns',
|
||||||
name: 'campaigns',
|
name: 'campaigns',
|
||||||
meta: { title: 'Campaigns', group: 'campaigns' },
|
meta: { title: 'globals.terms.campaigns', group: 'campaigns' },
|
||||||
component: () => import(/* webpackChunkName: "main" */ '../views/Campaigns.vue'),
|
component: () => import(/* webpackChunkName: "main" */ '../views/Campaigns.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/campaigns/media',
|
path: '/campaigns/media',
|
||||||
name: 'media',
|
name: 'media',
|
||||||
meta: { title: 'Media', group: 'campaigns' },
|
meta: { title: 'globals.terms.media', group: 'campaigns' },
|
||||||
component: () => import(/* webpackChunkName: "main" */ '../views/Media.vue'),
|
component: () => import(/* webpackChunkName: "main" */ '../views/Media.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/campaigns/templates',
|
path: '/campaigns/templates',
|
||||||
name: 'templates',
|
name: 'templates',
|
||||||
meta: { title: 'Templates', group: 'campaigns' },
|
meta: { title: 'globals.terms.templates', group: 'campaigns' },
|
||||||
component: () => import(/* webpackChunkName: "main" */ '../views/Templates.vue'),
|
component: () => import(/* webpackChunkName: "main" */ '../views/Templates.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/campaigns/analytics',
|
path: '/campaigns/analytics',
|
||||||
name: 'campaignAnalytics',
|
name: 'campaignAnalytics',
|
||||||
meta: { title: 'Campaign analytics', group: 'campaigns' },
|
meta: { title: 'analytics.title', group: 'campaigns' },
|
||||||
component: () => import(/* webpackChunkName: "main" */ '../views/CampaignAnalytics.vue'),
|
component: () => import(/* webpackChunkName: "main" */ '../views/CampaignAnalytics.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/campaigns/:id',
|
path: '/campaigns/:id',
|
||||||
name: 'campaign',
|
name: 'campaign',
|
||||||
meta: { title: 'Campaign', group: 'campaigns' },
|
meta: { title: 'globals.terms.campaign', group: 'campaigns' },
|
||||||
component: () => import(/* webpackChunkName: "main" */ '../views/Campaign.vue'),
|
component: () => import(/* webpackChunkName: "main" */ '../views/Campaign.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/settings',
|
path: '/settings',
|
||||||
name: 'settings',
|
name: 'settings',
|
||||||
meta: { title: 'Settings', group: 'settings' },
|
meta: { title: 'globals.terms.settings', group: 'settings' },
|
||||||
component: () => import(/* webpackChunkName: "main" */ '../views/Settings.vue'),
|
component: () => import(/* webpackChunkName: "main" */ '../views/Settings.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/settings/logs',
|
path: '/settings/logs',
|
||||||
name: 'logs',
|
name: 'logs',
|
||||||
meta: { title: 'Logs', group: 'settings' },
|
meta: { title: 'logs.title', group: 'settings' },
|
||||||
component: () => import(/* webpackChunkName: "main" */ '../views/Logs.vue'),
|
component: () => import(/* webpackChunkName: "main" */ '../views/Logs.vue'),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -122,18 +122,4 @@ const router = new VueRouter({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
|
||||||
if (to.matched.length === 0) {
|
|
||||||
next('/404');
|
|
||||||
} else {
|
|
||||||
next();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
router.afterEach((to) => {
|
|
||||||
Vue.nextTick(() => {
|
|
||||||
document.title = `${to.meta.title} / listmonk`;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|
Loading…
Reference in a new issue