mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
localize error messages from vee-validate
This commit is contained in:
parent
03ba88d7c7
commit
e1488e834e
@ -1,6 +1,9 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import VueI18n from 'vue-i18n'
|
import VueI18n from 'vue-i18n'
|
||||||
|
|
||||||
|
import en from 'vee-validate/dist/locale/en'
|
||||||
|
import de from 'vee-validate/dist/locale/de'
|
||||||
|
|
||||||
Vue.use(VueI18n)
|
Vue.use(VueI18n)
|
||||||
|
|
||||||
function loadLocaleMessages () {
|
function loadLocaleMessages () {
|
||||||
@ -11,6 +14,18 @@ function loadLocaleMessages () {
|
|||||||
if (matched && matched.length > 1) {
|
if (matched && matched.length > 1) {
|
||||||
const locale = matched[1]
|
const locale = matched[1]
|
||||||
messages[locale] = locales(key)
|
messages[locale] = locales(key)
|
||||||
|
if(locale === 'de') {
|
||||||
|
messages[locale] = {
|
||||||
|
validations: de,
|
||||||
|
...messages[locale]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(locale === 'en') {
|
||||||
|
messages[locale] = {
|
||||||
|
validations: en,
|
||||||
|
...messages[locale]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return messages
|
return messages
|
||||||
@ -33,14 +48,9 @@ const numberFormats = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default new VueI18n({
|
export default new VueI18n({
|
||||||
locale: 'en',
|
locale: 'en',
|
||||||
fallbackLocale: 'en',
|
fallbackLocale: 'en',
|
||||||
messages: loadLocaleMessages(),
|
messages: loadLocaleMessages(),
|
||||||
numberFormats
|
numberFormats
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -11,8 +11,8 @@
|
|||||||
"transactions":"transactions",
|
"transactions":"transactions",
|
||||||
"language":"Sprache",
|
"language":"Sprache",
|
||||||
"languages":{
|
"languages":{
|
||||||
"de": "Deutsch",
|
"de": "Deutsch",
|
||||||
"en": "English"
|
"en": "English"
|
||||||
},
|
},
|
||||||
"form": {
|
"form": {
|
||||||
"cancel":"Cancel",
|
"cancel":"Cancel",
|
||||||
@ -74,32 +74,32 @@
|
|||||||
"support":"Support"
|
"support":"Support"
|
||||||
},
|
},
|
||||||
"sidebar" : {
|
"sidebar" : {
|
||||||
"community":"Community",
|
"community":"Community",
|
||||||
"members_area":"Members area",
|
"members_area":"Members area",
|
||||||
"membership":"Membership"
|
"membership":"Membership"
|
||||||
},
|
},
|
||||||
"landing1" : {
|
"landing1" : {
|
||||||
"explore":"Explore Gradido",
|
"explore":"Explore Gradido",
|
||||||
"text":"If you want to get inspiration or just show something directly to your clients, you can jump start your development with our pre-built example pages.",
|
"text":"If you want to get inspiration or just show something directly to your clients, you can jump start your development with our pre-built example pages.",
|
||||||
"link":"Explore pages"
|
"link":"Explore pages"
|
||||||
},
|
},
|
||||||
"404" : {
|
"404" : {
|
||||||
"ooops" : "Ooops!",
|
"ooops" : "Ooops!",
|
||||||
"text" : "Page not found. Don't worry though, we have plenty of other pages to explore",
|
"text" : "Page not found. Don't worry though, we have plenty of other pages to explore",
|
||||||
"back" : "Back to dashboard!"
|
"back" : "Back to dashboard!"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin": {
|
"admin": {
|
||||||
"site": {
|
"site": {
|
||||||
"overview": {
|
"overview": {
|
||||||
"creation": "Creation",
|
"creation": "Creation",
|
||||||
"transience" : "Transience",
|
"transience" : "Transience",
|
||||||
"exchanged": "Exchanged",
|
"exchanged": "Exchanged",
|
||||||
"members" : "Members"
|
"members" : "Members"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
|
||||||
"nav": {
|
"nav": {
|
||||||
"features": "Features"
|
"features": "Features"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import Vue from 'vue';
|
|||||||
import DashboardPlugin from './plugins/dashboard-plugin';
|
import DashboardPlugin from './plugins/dashboard-plugin';
|
||||||
import App from './App.vue';
|
import App from './App.vue';
|
||||||
import i18n from './i18n.js';
|
import i18n from './i18n.js';
|
||||||
|
import VeeValidate from './vee-validate.js'
|
||||||
import VueCookies from 'vue-cookies';
|
import VueCookies from 'vue-cookies';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
|
|||||||
28
frontend/src/vee-validate.js
Normal file
28
frontend/src/vee-validate.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { configure, extend } from 'vee-validate'
|
||||||
|
import { required, email, min } from "vee-validate/dist/rules"
|
||||||
|
import i18n from './i18n'
|
||||||
|
|
||||||
|
|
||||||
|
configure({
|
||||||
|
defaultMessage: (field, values) => {
|
||||||
|
console.log('defaultMessage', field, value)
|
||||||
|
values._field_ = i18n.t(`fields.${field}`)
|
||||||
|
return i18n.t(`validations.messages.${values._rule_}`, values)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
extend('email', {
|
||||||
|
...email,
|
||||||
|
message: (_, values) => i18n.t('validations.messages.email', values)
|
||||||
|
})
|
||||||
|
|
||||||
|
extend('required', {
|
||||||
|
...required,
|
||||||
|
message: (_, values) => i18n.t('validations.messages.required', values)
|
||||||
|
})
|
||||||
|
|
||||||
|
extend('min', {
|
||||||
|
...min,
|
||||||
|
message: (_, values) => i18n.t('validations.messages.min', values)
|
||||||
|
})
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user