Nuxt ZodI18n
用于本地化 zod 错误消息的 Nuxt 模块。
查看 playground 以获取使用文档,测试将在稍后进行
特性
- 此库依赖于 @nuxtjs/i18n 。
- 为 zod 提供全局错误映射,请参阅 Zod ERROR_HANDLING
- 基于 ZodIssueCode 的 zod 错误翻译
- 翻译自定义错误的方法
快速设置
- 将
nuxt-zod-i18n
依赖项添加到您的项目
npx nuxi@latest module add nuxt-zod-i18n
- 将
nuxt-zod-i18n
添加到nuxt.config.ts
的modules
部分,在@nuxtjs/i18n
模块之前
export default defineNuxtConfig({
modules: ['nuxt-zod-i18n', '@nuxtjs/i18n']
})
就是这样!您现在可以在您的 Nuxt 应用程序中使用 Nuxt ZodI18n 了 ✨
开发
# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release