From dd8c697dfab6b5b0665edffa681896a1fd26c249 Mon Sep 17 00:00:00 2001 From: Brice Lechatellier Date: Thu, 31 Oct 2024 21:14:33 +1100 Subject: [PATCH 1/2] fix: update promise type --- packages/next-international/package.json | 2 +- .../src/app/server/create-get-current-locale.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/next-international/package.json b/packages/next-international/package.json index 504248c..11d29ff 100644 --- a/packages/next-international/package.json +++ b/packages/next-international/package.json @@ -1,6 +1,6 @@ { "name": "next-international", - "version": "1.3.0", + "version": "1.3.1", "description": "Type-safe internationalization (i18n) for Next.js", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/next-international/src/app/server/create-get-current-locale.ts b/packages/next-international/src/app/server/create-get-current-locale.ts index 6a21a49..05fe121 100644 --- a/packages/next-international/src/app/server/create-get-current-locale.ts +++ b/packages/next-international/src/app/server/create-get-current-locale.ts @@ -1,7 +1,7 @@ import { getLocaleCache } from './get-locale-cache'; -export function createGetCurrentLocale(): () => LocalesKeys { +export function createGetCurrentLocale(): () => Promise { return function getCurrentLocale() { - return getLocaleCache() as LocalesKeys; + return getLocaleCache() as Promise; }; } From 11a8f488f32f894120117f6a012f11acac27dc91 Mon Sep 17 00:00:00 2001 From: Tom Lienard Date: Thu, 31 Oct 2024 16:02:23 +0000 Subject: [PATCH 2/2] chore: update documentation --- docs/pages/docs/app-get-change-locale.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/pages/docs/app-get-change-locale.md b/docs/pages/docs/app-get-change-locale.md index f228982..c05fea5 100644 --- a/docs/pages/docs/app-get-change-locale.md +++ b/docs/pages/docs/app-get-change-locale.md @@ -44,8 +44,10 @@ export default function Page() { // Server Component import { getCurrentLocale } from '../../locales/server' -export default function Page() { - const locale = getCurrentLocale() +export default async function Page() { + // If you are using Next.js < 15, you don't need to await `getCurrentLocale`: + // const locale = getCurrentLocale() + const locale = await getCurrentLocale() return (

Current locale: {locale}