I tried following the documentation
https://payloadcms.com/docs/fields/overview#validationValidation function has translation function as an optional param, but when I use the same translation function, the error message still does not translate.
I have not extended i18 configuration. I am just using the
t
function and expecting payload to translate according to the language chosen by the user. Is there anything that I am missing.
validate: (value, { t }) => {
if (condition) return true;
return t(
"The URL must start with xyz"
);
}
The
t
function uses the keys defined in the translation files. Take a look at
en.json
for available keys and one of the errors in source to see how it can be used. Typically, it would take a string as
namespace:translationKey
.
Thank you very much.I think this is what i needed.