1
0

feat: use vue-i18n 9 for vue3

This commit is contained in:
Dominik Pschenitschni
2021-08-20 15:38:16 +02:00
parent 3d6aca3510
commit 7c3c2945f8
19 changed files with 123 additions and 71 deletions

View File

@ -1,11 +1,11 @@
import {i18n} from '@/i18n/setup'
import {i18n} from '@/i18n'
export const getErrorText = (r) => {
if (r.response && r.response.data) {
if(r.response.data.code) {
const path = `error.${r.response.data.code}`
const message = i18n.t(path)
const message = i18n.global.t(path)
// If message and path are equal no translation exists for that error code
if (path !== message) {
@ -30,7 +30,7 @@ export const getErrorText = (r) => {
export function error(e, context, actions = []) {
context.$notify({
type: 'error',
title: i18n.t('error.error'),
title: i18n.global.t('error.error'),
text: getErrorText(e),
actions: actions,
})
@ -40,7 +40,7 @@ export function error(e, context, actions = []) {
export function success(e, context, actions = []) {
context.$notify({
type: 'success',
title: i18n.t('error.success'),
title: i18n.global.t('error.success'),
text: getErrorText(e),
data: {
actions: actions,