-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: next-international V2 #361
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@QuiiBz sorry to bother, any update on this? |
It's still in progress. |
Any update on v2? |
Have you tried to chain the middleware? Wasn't able to find the original source, but here an example how you could do it (with authjs instead of lucia): https://github.com/noxify/t3-turbo-lucia/tree/main/apps/nextjs/src Maybe a workaround but should work until the new middleware is available. |
Hi @noxify, |
Maybe it could be easier than expected:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer having two separated files
Development branch for #359
Breaking changes
Single
createI18n
functionInstead of having two separate
createI18nClient
/createI18nServer
methods that needs to live in separate files and each expose distinct but similar methods (useI18n
/getI18n
), a singlecreateI18n
function is introduced to replace all of them.You can import from the same file the
getI18n
/getScopedI18n
methods, without worrying about client vs server - it's taken care of by next-international automatically. These functions both return aPromise
, which you can eitherawait
inside a Server Component oruse()
inside a Client Component.Before/after
Before
After
Improved middleware
Previously, it was complex to use next-international's middleware with custom code or external middlewares (e.g. next-auth). The improved
createI18nMiddleware
function now accepts a full middleware-like signature ((request: NextRequest) => NextResponse
) as the first argument, meaning you can very easily add custom logic:Before/after
Before
After
Removal of
I18nProviderClient
With the new approach in next-international v2, the
I18nProviderClient
component is no longer needed - you can simply remove it completely!Rename
getStaticParams
togenerateI18nStaticParams
The utility function used for static rendering in combinaison with Next.js'
generateStaticParams
function has been renamed fromgetStaticParams
togenerateI18nStaticParams
, in order to match the other function names:Before/after
Before
After
Rename locale helpers
The locale helper functions have been renamed to be more simple:
useCurrentLocale()
->getLocale()
getCurrentLocale()
->getLocale()
useChangeLocale()
(this one keeps theuse*
naming because it can only be used inside Client Components)