Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add with_path to languages map #152

Open
MuhammadSawalhy opened this issue Jul 20, 2023 · 1 comment
Open

Add with_path to languages map #152

MuhammadSawalhy opened this issue Jul 20, 2023 · 1 comment

Comments

@MuhammadSawalhy
Copy link

Maps here in this package should contain _with_path suffixes such that the following code will give a message error with the translated key:

import i18next from "i18next";
import { z } from "zod";
import { zodI18nMap } from "zod-i18n-map";
import enZod from "zod-i18n-map/locales/en/zod.json";

i18next.init({
  lng: "en",
  resources: {
    en: {
      zod: enZod,
      form: {
        paths: {
          userName: "User's name",
        },
      },
    },
  },
});

z.setErrorMap(
  zodI18nMap({
    ns: ["zod", "form"],
    handlePath: {
      keyPrefix: "paths",
    },
  })
);
z.object({ userName: z.string() }).parse({ userName: 1 });
// User's name should be string, received number
@MuhammadSawalhy MuhammadSawalhy changed the title Add with_path to the Arabic map Add with_path to the languages map Jul 20, 2023
@MuhammadSawalhy MuhammadSawalhy changed the title Add with_path to the languages map Add with_path to languages map Jul 20, 2023
@reinvanimschoot
Copy link

I was also under the impression this would work out of the box. Is there any update on this? It seems weird to have to copy all error messages and add your own path variants for them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants