QuiiBz / next-international

Type-safe internationalization (i18n) for Next.js
https://next-international.vercel.app
MIT License
1.19k stars 52 forks source link

Saving and loading language preference from persistent storage #391

Open zdychacek opened 3 months ago

zdychacek commented 3 months ago

Is your feature request related to a problem? Please describe. I am missing feature to load language preference from DB. I have a user table with language field and I would like to load this preference and set the language accordingly.

Describe the solution you'd like I am wondering about solution like resolveLocale calback, which should be allowed to do asynchronous call.

Describe alternatives you've considered I tried resolveLocaleFromRequest callback but this is called only if Next-Locale cookie is not set and callback is synchronous so there is no way to call DB. I am using Prisma and when I try to call DB, i got an error:

Error: PrismaClient is not configured to run in Vercel Edge Functions or Edge Middleware. In order to run Prisma Client on edge runtime, either:
 - Use Prisma Accelerate: https://pris.ly/d/accelerate
 - Use Driver Adapters: https://pris.ly/d/driver-adapters

If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report

Thanks for your work ont this project and I am waiting for you response.

Ondrej