Merge pull request #67 from gradido/lokalize-validation-messages

feat: Lokalize Validation Messages
This commit is contained in:
Ulf Gebhardt 2021-03-24 17:50:51 +01:00 committed by GitHub
commit e3b1ce00c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 135 additions and 119 deletions

View File

@ -39,7 +39,7 @@
"qrcode": "^1.4.4",
"quill": "^1.3.6",
"sweetalert2": "^9.5.4",
"vee-validate": "^3.2.1",
"vee-validate": "^3.4.5",
"vue": "^2.6.11",
"vue-bootstrap-typeahead": "^0.2.6",
"vue-chartjs": "^3.5.0",

View File

@ -17,54 +17,56 @@
</template>
<script>
import { ParticlesBg } from "particles-bg-vue";
import icon from "./icon.js";
import { ParticlesBg } from "particles-bg-vue";
import icon from "./icon.js"
import { localeChanged } from 'vee-validate'
export default {
name: 'app',
components: {
ParticlesBg
},
created () {
console.log( "xx", $cookies.get("gdd_lang"))
console.log('%cWillkommen bei Gradido %cgreen text', 'font-weight:bold', 'color: green')
if ( $cookies.isKey("gdd_session_id") == true) {
console.log('%cHey %c'+$cookies.get("gdd_u")+'', 'font-weight:bold', 'color: orange')
this.$store.commit('session_id', $cookies.get("gdd_session_id"))
this.$store.commit('email', $cookies.get("gdd_u"))
this.$store.commit('language', $cookies.get("gdd_lang"))
this.$i18n.locale = $cookies.get("gdd_lang")
this.$router.push("overview")
export default {
name: 'app',
components: {
ParticlesBg
},
created () {
console.log( "xx", $cookies.get("gdd_lang"))
console.log('%cWillkommen bei Gradido %cgreen text', 'font-weight:bold', 'color: green')
if ( $cookies.isKey("gdd_session_id") == true) {
console.log('%cHey %c'+$cookies.get("gdd_u")+'', 'font-weight:bold', 'color: orange')
this.$store.commit('session_id', $cookies.get("gdd_session_id"))
this.$store.commit('email', $cookies.get("gdd_u"))
this.$store.commit('language', $cookies.get("gdd_lang"))
this.$i18n.locale = $cookies.get("gdd_lang")
this.$router.push("overview")
}else {
console.log("app.vue to Logout")
this.$store.dispatch('logout')
}
},
data() {
return {
config: {
num: [1, 7],
rps: 15,
radius: [5, 50],
life: [6.5, 15],
v: [1, 1],
tha: [-40, 40],
body: icon,
alpha: [0.6, 0],
scale: [0.1, 0.4],
position: "all",
cross: "dead",
random: 2,
},
};
},
console.log("app.vue to Logout")
this.$store.dispatch('logout')
}
},
data() {
return {
config: {
num: [1, 7],
rps: 15,
radius: [5, 50],
life: [6.5, 15],
v: [1, 1],
tha: [-40, 40],
body: icon,
alpha: [0.6, 0],
scale: [0.1, 0.4],
position: "all",
cross: "dead",
random: 2,
},
};
},
methods: {
setLocale(locale) {
this.$i18n.locale = locale
this.$store.commit('language', this.$i18n.locale)
}
},
}
setLocale(locale) {
this.$i18n.locale = locale
this.$store.commit('language', this.$i18n.locale)
localeChanged(locale)
}
},
}
</script>
<style>

View File

@ -1,6 +1,9 @@
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import en from 'vee-validate/dist/locale/en'
import de from 'vee-validate/dist/locale/de'
Vue.use(VueI18n)
function loadLocaleMessages () {
@ -11,6 +14,18 @@ function loadLocaleMessages () {
if (matched && matched.length > 1) {
const locale = matched[1]
messages[locale] = locales(key)
if(locale === 'de') {
messages[locale] = {
validations: de,
...messages[locale]
}
}
if(locale === 'en') {
messages[locale] = {
validations: en,
...messages[locale]
}
}
}
})
return messages
@ -33,14 +48,9 @@ const numberFormats = {
}
}
export default new VueI18n({
locale: 'en',
fallbackLocale: 'en',
messages: loadLocaleMessages(),
numberFormats
})

View File

@ -11,8 +11,8 @@
"transactions":"transactions",
"language":"Sprache",
"languages":{
"de": "Deutsch",
"en": "English"
"de": "Deutsch",
"en": "English"
},
"form": {
"cancel":"Cancel",
@ -74,32 +74,32 @@
"support":"Support"
},
"sidebar" : {
"community":"Community",
"members_area":"Members area",
"membership":"Membership"
"community":"Community",
"members_area":"Members area",
"membership":"Membership"
},
"landing1" : {
"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.",
"link":"Explore pages"
"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.",
"link":"Explore pages"
},
"404" : {
"ooops" : "Ooops!",
"text" : "Page not found. Don't worry though, we have plenty of other pages to explore",
"back" : "Back to dashboard!"
"ooops" : "Ooops!",
"text" : "Page not found. Don't worry though, we have plenty of other pages to explore",
"back" : "Back to dashboard!"
}
},
"admin": {
"site": {
"overview": {
"creation": "Creation",
"transience" : "Transience",
"exchanged": "Exchanged",
"members" : "Members"
},
"admin": {
"site": {
"overview": {
"creation": "Creation",
"transience" : "Transience",
"exchanged": "Exchanged",
"members" : "Members"
}
}
}
},
},
"nav": {
"features": "Features"
}
}
}

View File

@ -2,6 +2,7 @@ import Vue from 'vue';
import DashboardPlugin from './plugins/dashboard-plugin';
import App from './App.vue';
import i18n from './i18n.js';
import VeeValidate from './vee-validate.js'
import VueCookies from 'vue-cookies';
// store

View File

@ -0,0 +1,27 @@
import { configure, extend } from 'vee-validate'
import { required, email, min } from "vee-validate/dist/rules"
import i18n from './i18n'
configure({
defaultMessage: (field, values) => {
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)
})

View File

@ -3,46 +3,16 @@
<template>
<div class="main-content">
<router-view></router-view>
<content-footer v-if="!$route.meta.hideFooter"></content-footer>
<content-footer v-if="!$route.meta.hideFooter"></content-footer>
</div>
</template>
</div>
</template>
<script>
import ContentFooter from './ContentFooter.vue';
export default {
components: {
ContentFooter
},
data() {
return {
year: new Date().getFullYear(),
pageClass: 'login-page'
};
},
computed: {
title() {
return `${this.$route.name} Page`;
}
},
methods: {
setLocale(locale) {
this.$i18n.locale = locale
//this.$router.push({
// params: { lang: locale }
//})
//this.hideDropdown()
}
}
};
import ContentFooter from './ContentFooter.vue'
export default {
components: {
ContentFooter
},
}
</script>
<style lang="scss">
.card { background-color:rgba(136, 130, 131, 0.3); }
</style>

View File

@ -1,13 +1,12 @@
<template>
<footer class="footer px-4 bg-transparent">
<b-row align-v="center" class="justify-content-lg-between">
<b-col><div class="copyright text-center text-lg-center text-muted">
© {{year}} <a href="#!" to="/login" class="font-weight-bold ml-1" >Gradido-Akademie</a>
</div></b-col>
</b-row>
<b-row align-v="center" class="justify-content-lg-between" >
<b-col>
<b-col>
<div class="copyright text-center text-lg-center text-muted">
© {{year}} <a href="https://gradido.net/" class="font-weight-bold ml-1" target="_blank">Gradido-Akademie</a>
</div>
</b-col>
<b-col>
<b-nav class="nav-footer justify-content-center">
<b-nav-item :href="`https://gradido.net/${$i18n.locale}`" target="_blank">
Gradido
@ -24,7 +23,14 @@
</b-nav>
</b-col>
</b-row>
<!--
<br>
<br>
<b-row >
<b-col class="nav-link text-center" @click.prevent="setLocale('en')">{{ $t('languages.en') }}</b-col>
<b-col class="nav-link text-center" @click.prevent="setLocale('de')">{{ $t('languages.de') }}</b-col>
</b-row>
-->
</footer>
</template>
<script>

View File

@ -11220,7 +11220,7 @@ vary@~1.1.2:
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=
vee-validate@^3.2.1:
vee-validate@^3.4.5:
version "3.4.5"
resolved "https://registry.yarnpkg.com/vee-validate/-/vee-validate-3.4.5.tgz#96a456c309f7bdb2cce62c3b554f96d893e9f6ae"
integrity sha512-ZEcLqOAZzSkMhDvPcTx0xcwVOijFnMW9J+BA20j+rDmo24T8RCCqVQyRwwrDrcWJZV2dRYl/yYNa2GB6UCoBvg==