feat(docs): update 14-internationalization.mdx (#62484)
### Improving Documentation follow the [example](https://github.com/vercel/next.js/blob/canary/examples/app-dir-i18n-routing/middleware.ts#L53), it is better to use NextResponse instead of Response.
This commit is contained in:
parent
7d4821de6f
commit
e98978033f
1 changed files with 2 additions and 1 deletions
|
@ -33,6 +33,7 @@ match(languages, locales, defaultLocale) // -> 'en-US'
|
|||
Routing can be internationalized by either the sub-path (`/fr/products`) or domain (`my-site.fr/products`). With this information, you can now redirect the user based on the locale inside [Middleware](/docs/app/building-your-application/routing/middleware).
|
||||
|
||||
```js filename="middleware.js"
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
let locales = ['en-US', 'nl-NL', 'nl']
|
||||
|
||||
|
@ -53,7 +54,7 @@ export function middleware(request) {
|
|||
request.nextUrl.pathname = `/${locale}${pathname}`
|
||||
// e.g. incoming request is /products
|
||||
// The new URL is now /en-US/products
|
||||
return Response.redirect(request.nextUrl)
|
||||
return NextResponse.redirect(request.nextUrl)
|
||||
}
|
||||
|
||||
export const config = {
|
||||
|
|
Loading…
Reference in a new issue