-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
zod-i18n-map not working with i18next in es module #204
Comments
Just ran into this. Found a temporary fix (hack) here. |
I am also having the same problem. @juetan |
This code works for me import { z } from "zod";
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import { makeZodI18nMap } from "zod-i18n-map";
import es from "../locales/es.json";
import en from "../locales/en.json";
import pt from "../locales/pt.json";
import zodEs from "zod-i18n-map/locales/es/zod.json";
import zodEn from "zod-i18n-map/locales/en/zod.json";
import zodPt from "zod-i18n-map/locales/pt/zod.json";
const resources = {
en: { translation: en, zod: zodEn },
es: { translation: es, zod: zodEs },
pt: { translation: pt, zod: zodPt },
};
i18n.use(initReactI18next).init({
resources,
lng: "es",
fallbackLng: "en",
});
z.setErrorMap(makeZodI18nMap({ t: i18n.t.bind(i18n) }));
export default i18n; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reproduction: https://stackblitz.com/edit/stackblitz-starters-vcpapm?file=index.js. just run
node ./index.js
.in above, set package.json's type to
module
.index.js
actually importi18next
's esm version, but importzod-i18n-map
's cjs version which importi18next
's cjs version. thei18next
is not the samethe solution would be: add
exports
field tozod-i18n-map
's package.json, just like whati18next
do.i would like to make a pr.
The text was updated successfully, but these errors were encountered: