You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
APIs](/docs/routing/navigation#localized-pathnames) in your components.
344
344
</Callout>
345
345
346
+
<details>
347
+
<summary>How can I revalidate localized pathnames?</summary>
348
+
349
+
Depending on if a route is generated statically (at build time) or dynamically (at runtime), [`revalidatePath`](https://nextjs.org/docs/app/api-reference/functions/revalidatePath) needs to be called either for the localized or the internal pathname.
350
+
351
+
Let's take an example with this folder structure:
352
+
```
353
+
app
354
+
└── [locale]
355
+
└── news
356
+
└── [slug]
357
+
```
358
+
359
+
… and this middleware configuration:
360
+
361
+
```tsx filename="middleware.ts"
362
+
importcreateMiddlewarefrom'next-intl/middleware';
363
+
364
+
exportdefaultcreateMiddleware({
365
+
defaultLocale: 'en',
366
+
locales: ['en', 'fr'],
367
+
pathnames: {
368
+
'/news/[slug]': {
369
+
en: '/news/[slug]',
370
+
fr: '/infos/[slug]'
371
+
}
372
+
}
373
+
});
374
+
```
375
+
376
+
Depending on whether `some-article` was included in [`generateStaticParams`](https://nextjs.org/docs/app/api-reference/functions/generate-static-params) or not, you can revalidate the route like this:
377
+
378
+
```tsx
379
+
// Statically generated at build time
380
+
revalidatePath('/fr/news/some-article')
381
+
382
+
// Dynamically generated at runtime:
383
+
revalidatePath('/fr/infos/some-article')
384
+
```
385
+
386
+
When in doubt, you can revalidate both paths to be on the safe side.
387
+
388
+
See also [`vercel/next.js#59825`](https://github.com/vercel/next.js/issues/59825).
389
+
390
+
</details>
391
+
392
+
346
393
### Matcher config
347
394
348
395
The middleware is intended to only run on pages, not on arbitrary files that you serve independently of the user locale (e.g. `/favicon.ico`).
0 commit comments