dobromir-hristov / vuelidate-error-extractor

Vuelidate form-group helper that extracts errors easily.
https://dobromir-hristov.github.io/vuelidate-error-extractor/
MIT License
138 stars 15 forks source link

i18n #25

Closed afwn90cj93201nixr2e1re closed 5 years ago

afwn90cj93201nixr2e1re commented 5 years ago

./del

afwn90cj93201nixr2e1re commented 5 years ago
function getI18nAttribute (attributes, fieldName) {
    var normalizedName = fieldName.replace(NORMALIZE_ATTR_REGEX, '');
    return this.$t(((this.$vuelidateErrorExtractor.i18nAttributes)+ "." + normalizedName));
}

Use like:

import i18n from './i18n'
import Vuelidate from "vuelidate";
import VuelidateErrorExtractor, { templates } from "vuelidate-error-extractor";

Vue.use(Vuelidate);
Vue.component("formWrapper", templates.FormWrapper);
Vue.use(VuelidateErrorExtractor, {
    templates,
    i18n:'validation',//json key from translation file
    i18nAttributes:'attributes',//don't know what shit is it
    messages:i18n.messages,//i18n.messages pointer
});

new Vue({
    router,
    store,
    validations: {},
    i18n,
    render: h => h(App)
}).$mount('#app');

Fix.