diff --git a/src/i18n/request.ts b/src/i18n/request.ts new file mode 100644 index 0000000..8cba4c4 --- /dev/null +++ b/src/i18n/request.ts @@ -0,0 +1,16 @@ +import {getRequestConfig} from 'next-intl/server'; +import {routing} from './routing'; + +export default getRequestConfig(async ({requestLocale}) => { + let locale = await requestLocale; + + // Ensure that the incoming locale is valid + if (!locale || !routing.locales.includes(locale as any)) { + locale = routing.defaultLocale; + } + + return { + locale, + messages: (await import(`../../messages/${locale}.json`)).default + }; +});