#Anyone using remix-i18next with remix-validated-form ?

1 messages · Page 1 of 1 (latest)

gloomy ginkgo
#

I'm unsure about how to have zod messages translated, would love some suggestions

solar dome
#

I would set my custom Zod messages to be error codes, then when I pass the code as key to i18next it can check if the key exists in the translation files

gloomy ginkgo
#

the problem is that this is incompatible with extracting messages from source code with something like i18next-parser

#

I'd have arbitrary translations in my locale files /:

gloomy ginkgo
#

well, ended up changing my validator declaration :

#
-export const validator = withZod(
+export const validator = (t: TFunction) => withZod(
  z.object({
    email: z
      .string()
      .min(3, { message: t("Email is required") })
      .email(t("Must be a valid email")),
    password: z.string().min(6, { message: t("Password is required") }),
  })
);
#

and I feed it t from my action and my view

#
export async function action({ request }: DataFunctionArgs) {
+  let t = await i18next.getFixedT(request);
+  const data = await validator(t).validate(await request.formData());
-  const data = await validator.validate(await request.formData());