Formik: How to handle i18n/localization?

Created on 6 Sep 2017  路  5Comments  路  Source: formium/formik

For example, if we are using yup schema for validation in formik, it is easy to translate messages, but problem occurs when we are using string().min() and the error message should be correct for a given number in min() validator.

Currently formik is adding error messages as a string, so it basically strips params from yup.ValidationError. In order to handle this, we have to somehow wrap all validators in yup to custom validators, just to translate messages correctly.

Is there a way how to handle this in formik?

Question

Most helpful comment

hey guys yup has support for i18n! https://github.com/jquense/yup#using-a-custom-locale-dictionary

All 5 comments

AFAIK Yup doesn't have a way of dealing with i18n. Thus, i would pick another validation library instead and pass its output to validate.

@michalkvasnicak If you settle on a validation lib you like that supports i18n, would you mind leaving a comment here so I can make an example for the Formik documentation?

hey guys yup has support for i18n! https://github.com/jquense/yup#using-a-custom-locale-dictionary

I stand corrected ^^

Yes it has, but I didn't know that it supports functions in locale until yesterday's evening, so now this issue can be closed :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pmonty picture pmonty  路  3Comments

outaTiME picture outaTiME  路  3Comments

giulioambrogi picture giulioambrogi  路  3Comments

Jucesr picture Jucesr  路  3Comments

Jungwoo-An picture Jungwoo-An  路  3Comments