Reputation: 15
I think I have set all the language settings for vee-validate but it still defaults to the English language error! I want to display the errors in Farsi language. I have also installed the necessary packages.
plugins->validation :
import {
Form as VeeForm, Field as VeeField, defineRule, ErrorMessage, configure,} from "vee-validate";
import {
required, min, max,alpha_spaces as alphaSpaces, email, min_value as minValue, max_value as maxValue, confirmed, not_one_of as excluded} from "@vee-validate/rules";
import { localize, setLocale } from "@vee-validate/i18n";
import fa from "@vee-validate/i18n/dist/locale/fa.json";
export default defineNuxtPlugin((ctx) => {
defineRule("required", required);
defineRule("terms", required);
defineRule("min", min);
defineRule("email", email);
defineRule("max", max);
defineRule("alpha_spaces", alphaSpaces);
defineRule("min_value", minValue);
defineRule("max_value", maxValue);
defineRule("passwords_mismatch", confirmed);
defineRule("excluded", excluded);
defineRule("country_excluded", excluded);
configure({
generateMessage: localize("fa", {
messages: {
required: `the ضروری استd`,
min: "فیلد {field} خیلی کوتاه است",
email: "فیلد {field} ایمیل معتبر نیست",
max: "فیلد {field} خیلی بلند است",
alpha_spaces: "فیلد {field} فقط میتواند شامل حروف و فاصله باشد",
min_value: "فیلد {field} خیلی کم است",
max_value: "فیلد {field} خیلی زیاد است",
passwords_mismatch: "رمزهای عبور مطابقت ندارند",
excluded: "شما نمیتوانید از این مقدار برای فیلد {field} استفاده کنید",
},
}),
validateOnBlur: true,validateOnChange: true,validateOnInput: false,validateOnModelUpdate: true,});
setLocale("fa");
});
The project is created with nuxt 3 and I use yup for validation. I have a general input component to which I send values with props. I have entered yup in the input component and the form schema is given in the parent component. The error of each input is in the same general input component.The error is displayed in English, not in Persian.
Upvotes: 0
Views: 24