Skip to content

Commit

Permalink
#74 fixed page title with translator
Browse files Browse the repository at this point in the history
  • Loading branch information
kotte-sanya committed Aug 14, 2020
1 parent 671b7e3 commit eb0b8d9
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 23 deletions.
23 changes: 23 additions & 0 deletions spa/src/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,28 @@
"show-all":"Zobrazit vše",
"reply": "Odpovědět",
"close": "Zavřít"
},
"page-title":{
"home": "Domov",
"sign-up": "Přihlásit se",
"sign-in": "Přihlásit se",
"activate": "aktivovat",
"verify": "Ověřte",
"forgotten": "Zapomenutý",
"reset": "Resetovat",
"update-password": "Aktualizujte heslo",
"user-profile": "Uživatelský profil",
"update-profile": "Aktualizovat profil",
"polls": "Ankety",
"poll": "Anketa",
"edit-poll": "Upravit anketa",
"create-poll": "Vytvořit anketa",
"analyse-poll": "Analyzujte anketa",
"analyze-votes": "Analyzujte hlasy",
"help": "Nápověda",
"mission": "Mise",
"contact": "Kontakt",
"advertisement": "Reklama",
"not-found": "Stránka nenalezena"
}
}
23 changes: 23 additions & 0 deletions spa/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,28 @@
"show-all":"Show all",
"reply": "Reply",
"close": "Close"
},
"page-title":{
"home": "Home",
"sign-up": "Sign up",
"sign-in": "Sign in",
"activate": "Activate",
"verify": "Verify",
"forgotten": "Forgotten",
"reset": "Reset",
"update-password": "Update password",
"user-profile": "User profile",
"update-profile": "Update profile",
"polls": "Polls",
"poll": "Poll",
"edit-poll": "Edit poll",
"create-poll": "Create poll",
"analyse-poll": "Analyse poll",
"analyze-votes": "Analyze votes",
"help": "Help",
"mission": "Mission",
"contact": "Contact",
"advertisement": "Advertisement",
"not-found": "Page not found"
}
}
45 changes: 24 additions & 21 deletions spa/src/router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Vue from 'vue';
import Router from 'vue-router';
import i18n from './i18n';
import Home from './views/Home.vue';
import store from './store';

Expand All @@ -24,6 +25,8 @@ const requireAuth = (to, from, next) => {
next({ name: 'sign-in' });
};

const _t = key => i18n.t(`page-title.${key}`);

export default new Router({
mode: 'history',
base: process.env.BASE_URL,
Expand All @@ -32,143 +35,143 @@ export default new Router({
path: '/',
name: 'home',
component: Home,
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/registrace',
name: 'sign-up',
component: () => import('./views/user/SignUp.vue'),
beforeEnter: requireUnauth,
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/prihlaseni',
name: 'sign-in',
component: () => import('./views/user/SignIn.vue'),
beforeEnter: requireUnauth,
props: true,
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/aktivace-uzivatele',
name: 'activate',
component: () => import('./views/user/Confirm.vue'),
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/overeni-uzivatele/:token',
name: 'verify',
component: () => import('./views/user/Verify.vue'),
beforeEnter: requireUnauth,
props: true,
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/zapomenute-heslo',
name: 'forgotten',
component: () => import('./views/user/ForgottenPassword'),
beforeEnter: requireUnauth,
props: true,
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/nastaveni-hesla/:resetPasswordToken',
name: 'reset',
component: () => import('./views/user/ResetPassword.vue'),
beforeEnter: requireUnauth,
props: true,
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/zmena-hesla',
name: 'update-password',
component: () => import('./views/user/ChangePassword'),
beforeEnter: requireAuth,
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/profil/:id',
name: 'user-profile',
component: () => import('./views/user/Profile.vue'),
props: true,
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/uprava-profilu',
name: 'update-profile',
component: () => import('./views/user/UpdateProfile.vue'),
beforeEnter: requireAuth,
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/ankety/',
name: 'polls',
component: () => import('./views/poll/Polls.vue'),
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/anketa/:slug',
name: 'poll',
component: () => import('./views/poll/Poll.vue'),
props: true,
meta: { title: route => `${route.name}/${route.params.slug}` },
meta: { title: route => `${_t(route.name)}\xa0\xa0-\xa0\xa0` },
},
{
path: '/uprava-ankety/:slug',
name: 'edit-poll',
component: () => import('./views/poll/EditPoll.vue'),
props: true,
meta: { title: route => `${route.name}/${route.params.slug}` },
meta: { title: route => `${_t(route.name)}\xa0\xa0-\xa0\xa0` },
},
{
path: '/nova-anketa/',
name: 'create-poll',
component: () => import('./views/poll/CreatePoll'),
props: true,
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/anketa/:slug/grafy/:type',
name: 'analyse-poll',
component: () => import('./views/poll/AnalyzeVotes'),
props: true,
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/analyze-votes/:id',
name: 'analyze-votes',
component: () => import('./views/poll/AnalyzeVotes.vue'),
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/napoveda',
name: 'help',
component: () => import('./views/site/Help.vue'),
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/mise',
name: 'mission',
component: () => import('./views/site/Mission.vue'),
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/kontakt',
name: 'contact',
component: () => import('./views/site/Contact.vue'),
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '/reklama',
name: 'advertisement',
component: () => import('./views/site/Advertisement.vue'),
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
{
path: '*',
name: 'not-found',
component: () => import('./views/site/404.vue'),
meta: { title: route => route.name },
meta: { title: route => _t(route.name) },
},
],
scrollBehavior(to, from, savedPosition) {
Expand Down
4 changes: 3 additions & 1 deletion spa/src/views/poll/EditPoll.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export default {
},
computed: {
poll() {
return this.$store.getters.POLL;
const poll = this.$store.getters.POLL;
if (poll) document.title += poll.info.caption;
return poll;
},
role() {
return this.$store.getters.USER_ROLE[0] === 'admin:poll';
Expand Down
4 changes: 3 additions & 1 deletion spa/src/views/poll/Poll.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export default {
},
computed: {
poll() {
return this.$store.getters.POLL;
const poll = this.$store.getters.POLL;
if (poll) document.title += poll.info.caption;
return poll;
},
role() {
return (this.$store.getters.USER_ROLE) ? this.$store.getters.USER_ROLE[0] === 'admin:poll' : false;
Expand Down

0 comments on commit eb0b8d9

Please sign in to comment.