Multilingual error messages for Zod — starting with English 🇬🇧 and Bangla 🇧🇩. Keep your validation errors human-friendly, localized, and developer-friendly ✨
Using npm:
Using yarn:
Using pnpm:
1. Import and set locale globally
import { z } from "zod";
import { withBhasha, setLocale } from "zod-bhasha";
// Enable zod-bhasha
withBhasha(z);
// Set Bangla as default locale
setLocale("bn");
const schema = z.string().min(5);
console.log(schema.safeParse("hi").error?.format());
// Output (Bangla): "কমপক্ষে ৫ অক্ষর হতে হবে"
2. Override locale per validation
import { z } from "zod";
import { withBhasha } from "zod-bhasha";
withBhasha(z);
const schema = z.string().email();
console.log(schema.safeParse("invalid", { locale: "en" }).error?.format());
// Output: "Invalid email address"
console.log(schema.safeParse("invalid", { locale: "bn" }).error?.format());
// Output: "ইমেইল ঠিকানা সঠিক নয়"
- 🇬🇧 English (
en)
- 🇧🇩 Bangla (
bn)
🔜 More languages coming soon! Contributions welcome 🎉
- Fork the repo 🍴
- Create a feature branch 🌱
- Add your locale / improvements
- Submit a PR 🚀
MIT © 2025 — Made with ❤️ by [Md Sifat Bin Jibon]
Github repo:- https://github.com/Md-Sifat-code/zod-bhasha