From e931132342a9cc3ba539e6f00f33a7016a134f02 Mon Sep 17 00:00:00 2001 From: luciano Date: Wed, 29 Apr 2026 14:37:39 +0200 Subject: [PATCH] fix(web): switch i18n.ts to await requestLocale (next-intl 3.22+) The `locale` parameter passed to getRequestConfig is deprecated; next-intl now provides `requestLocale` as a Promise. Resolve it at the top of the callback, fall back to defaultLocale when the requested one isn't supported, and return both locale and messages. Removes the per-request deprecation warning in dev/E2E logs. Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/web/src/i18n.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/web/src/i18n.ts b/apps/web/src/i18n.ts index ca7d5f9..8e9118c 100644 --- a/apps/web/src/i18n.ts +++ b/apps/web/src/i18n.ts @@ -1,4 +1,3 @@ -import { notFound } from 'next/navigation'; import { getRequestConfig } from 'next-intl/server'; export const locales = ['it'] as const; @@ -6,13 +5,14 @@ export const defaultLocale = 'it' as const; export type Locale = (typeof locales)[number]; -export default getRequestConfig(async ({ locale }) => { - if (!locales.includes(locale as Locale)) { - notFound(); - } +export default getRequestConfig(async ({ requestLocale }) => { + const requested = await requestLocale; + const locale: Locale = locales.includes(requested as Locale) + ? (requested as Locale) + : defaultLocale; return { - locale: locale as Locale, + locale, messages: (await import(`../messages/${locale}.json`)).default, }; });