noxify / t3-turbo-lucia

Turborepo stack ( based on t3-turbo ) with lucia-auth instead of authjs/nextauth
MIT License
24 stars 4 forks source link

Add i18n messages to Zod errors in BE/FE #8

Open dBianchii opened 3 months ago

dBianchii commented 3 months ago

Hi @noxify, I just wanted to say thanks for adding my name in the README. More people should be using this repo. Too bad it hasn't gotten too much visibility.

I was initially going to contact you on socials to talk about this and other things for this repo, but didn't find anything in your profile.

So, I just wanted to know, have you thought about or tried to add i18n zod messages (https://www.npmjs.com/package/zod-i18n-map) integrated with next-international? I am going to attempt doing this one day or the other, but couldn't find an easy way to do it for this repo.

Oh, on a side note, I wanted to share that I am officially moving off of next-auth and going to use lucia. I was following ct3-turbo normally, but had so many hiccups making it work for my needs and for mobile. This repo opened my eyes to how much less abstracted lucia is and how much more control it gives you. I used this as a base for my PR moving off of next-auth and wanted to thank you for it. (Also, in case you are interested, once I make auth work on mobile with lucia, I can provide a PR here to adapt a minimal solution for expo)

noxify commented 3 months ago

Hi @dBianchii ,

Thanks for the kind words.

Haven't tried the mentioned package, but we're currently refactoring an internal app - will give it a try.

If you want, I can invite you to the repo and you can push the relevant changes for mobile auto directly.

Unfortunately I have no experience with expo (that's also the reason why I removed it from the repo πŸ™ˆ)

The easiest way to contact me is via discord (noxy88) but I followed you on X and Instagram - hope this helps to find me 🫑

noxify commented 3 months ago

Hi @dBianchii ,

spent some time to evaluate the usage of next-international together with the custom error map ( via z.setErrorMap ).

For me, it seems that it could work if you're in a react context ( since next-international uses some react specific functions in their server & client code ).

This could work in some usecases, but if you plan to use the same validations in your backend app, I think this will not work.

Possible solutions:

a) switch to a different i18n package b) use the custom error map only in a react based app c) creating a "lightweight i18n wrapper" ( based on international-types ) to be able to use the same validations in your frontend&backend

What do you think?

dBianchii commented 3 months ago

I want i18n really to be all around my app. Everything the user sees must be translated for what I need. Even in the future, I need my expo app to be fully translated.

I see that now, the api folder in NextJS is outside of the [locale] folder, which might make things more difficult. I was even thinking of defining the locale based on 'accept-language' headers and setting the i18n helper in tRPC context or something.

I've been wanting to try out other libraries to see what they have to offer. I just picked next-international because of this repo and also because I saw Katt from tRPC core team and you were sponsoring it.

I guess I'll try in the not so distant future some ideas, and I'll definitely update this in the future in case I find a solution.

dBianchii commented 1 week ago

Hi @noxify I received a notification from you on Twitter, but I can't open the app because it has been blocked/banned in Brazil recently. Interesting to see that notifications are still going through though.

Please reach me here on Instagram: https://www.instagram.com/gdbianchii?igsh=aWVrZGI0aXRudXV6&utm_source=qr

Or LinkedIn if you prefer: https://www.linkedin.com/in/gabriel-bianchi-8137ab212?utm_source=share&utm_campaign=share_via&utm_content=profile&utm_medium=ios_app

I'm sending the message here bc I don't know how else to reach you πŸ˜€