Text for 403 error is localized

I hacked the error.vue to catch the default 404 error message and to display a localized message instead. I found no better way to do it. Any ideas?
This commit is contained in:
Moriz Wahl 2020-01-20 22:55:22 +01:00
parent a4907f2bcb
commit 7315cacb5a
5 changed files with 12 additions and 5 deletions

View File

@ -2,7 +2,10 @@
<div class="error-container">
<base-icon class="error-icon" name="exclamation-circle" />
<br />
<span class="error-message">{{ $t(error.message) }}</span>
<span v-if="error.message === 'This page could not be found'" class="error-message">
{{ $t('error-pages.default') }}
</span>
<span v-else class="error-message">{{ $t(error.message) }}</span>
<br />
<nuxt-link to="/">{{ $t('error-pages.back-to-index') }}</nuxt-link>
</div>

View File

@ -803,6 +803,8 @@
"profile-not-found": "Dieses Profil konnte nicht gefunden werden",
"back-to-index": "Zurück zur Startseite",
"post-not-found": "Dieser Beitrag konnte nicht gefunden werden",
"cannot-edit-post": "Dieser Beitrag kann nicht editiert werden"
"cannot-edit-post": "Dieser Beitrag kann nicht editiert werden",
"default": "Diese Seite konnte nicht gefunden werden",
"not-authorized": "Kein Zugang zu dieser Seite"
}
}

View File

@ -803,7 +803,9 @@
"profile-not-found": "This profile could not be found",
"back-to-index": "Back to index page",
"post-not-found": "This post could not be found",
"cannot-edit-post": "This post cannot be edited"
"cannot-edit-post": "This post cannot be edited",
"default": "This page could not be found",
"not-authorized": "Not authorized to this page"
}
}

View File

@ -1,5 +1,5 @@
export default ({ store, error }) => {
if (!store.getters['auth/isAdmin']) {
return error({ statusCode: 403 })
return error({ statusCode: 403, message: 'error-pages.not-authorized' })
}
}

View File

@ -1,5 +1,5 @@
export default ({ store, error }) => {
if (!store.getters['auth/isModerator']) {
return error({ statusCode: 403 })
return error({ statusCode: 403, message: 'error-pages.not-authorized' })
}
}