diff --git a/examples/example-app-router-playground/package.json b/examples/example-app-router-playground/package.json index b48c12401..91bf502f7 100644 --- a/examples/example-app-router-playground/package.json +++ b/examples/example-app-router-playground/package.json @@ -15,10 +15,10 @@ "dependencies": { "lodash": "^4.17.21", "ms": "2.1.3", - "next": "^14.2.3", + "next": "15.0.0-rc.0", "next-intl": "latest", - "react": "^18.3.0", - "react-dom": "^18.3.0" + "react": "19.0.0-rc-f994737d14-20240522", + "react-dom": "19.0.0-rc-f994737d14-20240522" }, "devDependencies": { "@jest/globals": "^29.5.0", diff --git a/examples/example-app-router-playground/src/config.tsx b/examples/example-app-router-playground/src/config.tsx new file mode 100644 index 000000000..f64b9c956 --- /dev/null +++ b/examples/example-app-router-playground/src/config.tsx @@ -0,0 +1,33 @@ +import {Pathnames} from 'next-intl/navigation'; + +export const defaultLocale = 'en'; + +export const locales = ['en', 'de', 'es', 'ja'] as const; + +export const localePrefix = + process.env.NEXT_PUBLIC_LOCALE_PREFIX === 'never' ? 'never' : 'as-needed'; + +export const pathnames = { + '/': '/', + '/client': '/client', + '/client/redirect': '/client/redirect', + '/nested': { + en: '/nested', + de: '/verschachtelt', + es: '/anidada', + ja: '/ネスト' + }, + '/redirect': '/redirect', + '/news/[articleId]': { + en: '/news/[articleId]', + de: '/neuigkeiten/[articleId]', + es: '/noticias/[articleId]', + ja: '/ニュース/[articleId]' + }, + '/news/just-in': { + en: '/news/just-in', + de: '/neuigkeiten/aktuell', + es: '/noticias/justo-en', + ja: '/ニュース/現在' + } +} satisfies Pathnames; diff --git a/examples/example-app-router-playground/src/i18n.tsx b/examples/example-app-router-playground/src/i18n.tsx index afa2b150c..fc26c0a01 100644 --- a/examples/example-app-router-playground/src/i18n.tsx +++ b/examples/example-app-router-playground/src/i18n.tsx @@ -2,7 +2,7 @@ import {headers} from 'next/headers'; import {notFound} from 'next/navigation'; import {getRequestConfig} from 'next-intl/server'; import defaultMessages from '../messages/en.json'; -import {locales} from './navigation'; +import {locales} from './config'; export default getRequestConfig(async ({locale}) => { // Validate that the incoming `locale` parameter is valid diff --git a/examples/example-app-router-playground/src/middleware.ts b/examples/example-app-router-playground/src/middleware.ts index 5ab0397ee..83fb81949 100644 --- a/examples/example-app-router-playground/src/middleware.ts +++ b/examples/example-app-router-playground/src/middleware.ts @@ -1,5 +1,5 @@ import createMiddleware from 'next-intl/middleware'; -import {locales, pathnames, localePrefix, defaultLocale} from './navigation'; +import {locales, pathnames, localePrefix, defaultLocale} from './config'; export default createMiddleware({ defaultLocale, diff --git a/examples/example-app-router-playground/src/navigation.tsx b/examples/example-app-router-playground/src/navigation.tsx index 3bcbd3c99..50f5cafb7 100644 --- a/examples/example-app-router-playground/src/navigation.tsx +++ b/examples/example-app-router-playground/src/navigation.tsx @@ -1,39 +1,5 @@ -import { - createLocalizedPathnamesNavigation, - Pathnames -} from 'next-intl/navigation'; - -export const defaultLocale = 'en'; - -export const locales = ['en', 'de', 'es', 'ja'] as const; - -export const localePrefix = - process.env.NEXT_PUBLIC_LOCALE_PREFIX === 'never' ? 'never' : 'as-needed'; - -export const pathnames = { - '/': '/', - '/client': '/client', - '/client/redirect': '/client/redirect', - '/nested': { - en: '/nested', - de: '/verschachtelt', - es: '/anidada', - ja: '/ネスト' - }, - '/redirect': '/redirect', - '/news/[articleId]': { - en: '/news/[articleId]', - de: '/neuigkeiten/[articleId]', - es: '/noticias/[articleId]', - ja: '/ニュース/[articleId]' - }, - '/news/just-in': { - en: '/news/just-in', - de: '/neuigkeiten/aktuell', - es: '/noticias/justo-en', - ja: '/ニュース/現在' - } -} satisfies Pathnames; +import {createLocalizedPathnamesNavigation} from 'next-intl/navigation'; +import {locales, localePrefix, pathnames} from './config'; export const {Link, redirect, usePathname, useRouter} = createLocalizedPathnamesNavigation({