xibman / nuxt-zod-i18n Goto Github PK
View Code? Open in Web Editor NEWEasily Translate Zod's error messages on nuxt
Home Page: http://xibman-nuxt-zod-i18n.nuxt.space/
Easily Translate Zod's error messages on nuxt
Home Page: http://xibman-nuxt-zod-i18n.nuxt.space/
I can't even find the nuxt-zod-i18n import in your playground. On my side, the installation and configuration settings don't work. Errors are not translated. Do you have a working example in a codePen or something?
Hello, I added Russian translation to localization. Thanks for module
I've added turkish translation to localazy thanks for module
Hello, is it possible to have a custom error message for specific fields, without redefining the validation logic?
I have this schema
export const userSchema = z.object({
chosenDate: z
.array(z.enum(['saturday', 'sunday']))
.min(1)
.max(2),
peopleAmount: z.enum(['1', '2', '3', '4', '5', '6', '7', '8']),
email: z.string().email(),
marketingPermission: z.literal(true),
termsAndConditions: z.literal(true),
});
how can I have a custom error message for the marketingPermission
and termsAndConditions
, without globally overriding the invalid_literal
error code? I mean I want two different error messages for both, but the same validation.
I know that I could do something like this:
marketingPermission: z.literal(true).refine((value) => value === true, { params: { i18n: 'acceptMarketingPermissionError' } })
but I don't like this approach because I don't want to redefine the validation logic of z.literal
.
Do you understand my issue?
Thank you and kind regards🙂
I want to download a translation from localazy and add it to my project. How can I do that?
Hi, I'm trying to override an error translation but my schema is a z.discriminatedUnion
and I don't understand what I'm doing wrong, I'm still having the default error from the translated errors of this library.
That's the schema:
const triggerSchema = z.discriminatedUnion('type', [
likeTriggerSchema,
dislikeTriggerSchema,
]).refine(data => ['dislike', 'like'].includes(data.type), {
path: ['type'],
params: { i18n: 'errors.trigger.unknownType' },
})
I'm using Nuxt UI, so the schema is used by the Form
component.
add translation Chinese language
v1.3.0
https://stackblitz.com/edit/nuxt-starter-dpc9kz?file=nuxt.config.ts
I installed nuxt-zod-i18n
after I had already been using @nuxtjs/i18n
for a while. I added it to the modules
in the nuxt.config.ts
and got the error that 't' of 'i18n' is undefined.
and therefore cannot be accessed.
The same error happened in a minimal stackblitz reproduction (also linked above).
No response
[nuxt] [request error] [unhandled] [500] Cannot destructure property 't' of 'i18n' as it is undefined.
at ./node_modules/.pnpm/[email protected][email protected]/node_modules/nuxt-zod-i18n/dist/runtime/plugin.mjs:10:11
at ./virtual:nuxt:/Users/zoeykaiser/Documents/Development/Sidestream/dikoma/.nuxt/plugins/server.mjs:52:89
at Module.executeAsync (./node_modules/.pnpm/[email protected]/node_modules/unctx/dist/index.mjs:111:19)
at setup (./virtual:nuxt:/Users/zoeykaiser/Documents/Development/Sidestream/dikoma/.nuxt/plugins/server.mjs:52:65)
at ./node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/nuxt/dist/app/nuxt.js:116:60
at fn (./node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/nuxt/dist/app/nuxt.js:191:44)
at Object.callAsync (./node_modules/.pnpm/[email protected]/node_modules/unctx/dist/index.mjs:68:55)
at ./node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/nuxt/dist/app/nuxt.js:193:56
at Object.runWithContext (./node_modules/.pnpm/@[email protected]/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3998:18)
at callWithNuxt (./node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/nuxt/dist/app/nuxt.js:193:24)
In my instance of @nuxtjs/i18n
, I use different code
from the base ones (i.e. it-IT
, en-GB
, etc...) so this module doesn't find the relative translation path. It could be added, in the configuration inside nuxt.config
, the chance to map the json files in the module, with specific user-defined code
.
Line 75 in 497331f
No response
v1.4.0
Actually, is not possible to use nuxt-zod-i18n
with external @nuxtjs/i18n
configuration file like i18n.config.ts
.
nuxt-zod-i18n
only load i18n configuration from the nuxt.config.ts
file. See this line:
Line 42 in 0f85d9a
We need to be able to load the configuration of this external file, based on the path defined in the Nuxt configuration or './i18n.config.ts'
by default.
export default defineNuxtConfig({
// ...
i18n: {
vueI18n: './my-i18n.config.ts' // optional, './i18n.config.ts' by default
}
})
No response
No response
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.