1
0

Add translations (#562)

Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/562
Co-authored-by: konrad <konrad@kola-entertainments.de>
Co-committed-by: konrad <konrad@kola-entertainments.de>
This commit is contained in:
konrad
2021-06-23 23:24:57 +00:00
parent 5badb65037
commit f0498fd767
103 changed files with 2306 additions and 973 deletions

View File

@ -1,29 +1,44 @@
const getText = t => {
export const getErrorText = (r, $t) => {
if (t.response && t.response.data && t.response.data.message) {
return [
t.message,
t.response.data.message
]
if (r.response && r.response.data) {
if(r.response.data.code) {
const path = `error.${r.response.data.code}`
const message = $t(path)
// If message and path are equal no translation exists for that error code
if (path !== message) {
return [
r.message,
message,
]
}
}
if (r.response.data.message) {
return [
r.message,
r.response.data.message,
]
}
}
return [t.message]
return [r.message]
}
export default {
error(e, context, actions = []) {
error(e, context, $t, actions = []) {
context.$notify({
type: 'error',
title: 'Error',
text: getText(e),
title: $t('error.error'),
text: getErrorText(e, $t),
actions: actions,
})
},
success(e, context, actions = []) {
success(e, context, $t, actions = []) {
context.$notify({
type: 'success',
title: 'Success',
text: getText(e),
title: $t('error.success'),
text: getErrorText(e, $t),
data: {
actions: actions,
},