Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 如何翻译veevalidate中的错误消息?_Laravel_Vue.js_Vee Validate - Fatal编程技术网

Laravel 如何翻译veevalidate中的错误消息?

Laravel 如何翻译veevalidate中的错误消息?,laravel,vue.js,vee-validate,Laravel,Vue.js,Vee Validate,在laravel中,我使用vue和veevalidate实时验证表单。 问题是错误消息以英文出现在veevalidate页面上,示例对我来说不是很清楚。 有人能指引我吗? 从“vee validate”导入vee validate; 从“vee validate”导入{Validator}; 常量字典={ 自定义:{ 电邮:{ 必填项:“描述tu电子邮件”, min:‘Túemail es muy corto’, 电子邮件:“invalido” }, 姓名:{ 必需:()=>“描述名称”

在laravel中,我使用vue和veevalidate实时验证表单。 问题是错误消息以英文出现在veevalidate页面上,示例对我来说不是很清楚。 有人能指引我吗?


从“vee validate”导入vee validate;
从“vee validate”导入{Validator};
常量字典={
自定义:{
电邮:{
必填项:“描述tu电子邮件”,
min:‘Túemail es muy corto’,
电子邮件:“invalido”
},
姓名:{
必需:()=>“描述名称”
}
}
};
Vue.使用(VeeValidate{
班级:对,
类名:
{
有效:“是有效的”,
无效:“是无效的”
}
});
导出默认值{
安装的(){
console.log('validador')
本地化(字典);
}
}

名义:
科雷奥电气公司
  • {{error}
{{errors.first('email')} 康瑟斯尼娜 Confirmar contraseña 登记员
在主配置文件中,必须导入区域设置并设置主区域设置

import attributesEs from 'vee-validate/dist/locale/es'
import attributesEn from 'vee-validate/dist/locale/en'
import VeeValidate, { Validator } from 'vee-validate'

window.Vue = Vue

Validator.localize('es',attributesEs);

Vue.use(VeeValidate, {
  locale: 'es',
  errorBagName: 'validations',
  fieldsBagName: 'inputs',
  dictionary: {
    translationsEn: { attributes: attributesEn },
    translationsEs: { attributes: attributesEs }
  }
});
在您必须添加的每个输入中:data vv as=“$t('key_to_translate')” 例如:

<div class="form-group" :class="{'has-error': validations.has('width') }">
    <label for="width">{{$t('Width')}}</label>
    <input type="number" id="width" name="width" class="form-control" 
           :placeholder="$t('Width')" v-model="form.width"
           v-validate="'required'" :data-vv-as="$t('Width')">
    <span class="text-danger" v-if="validations.has('width') "
                              v-text="validations.first('width')"></span>
</div>

{{$t('Width')}

在这个例子中,我也使用$t()。。vue-i18n软件包的一种方法

请将您的问题翻译成英语。您必须在这里用英语向西班牙语社区提问的成员:我投票结束这个问题,因为它应该在es.stackoverflow.com上,谢谢您的早期回答,我尝试您的推荐。