frontend and backend base setup
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import {getRequestConfig} from 'next-intl/server';
|
||||
import {routing} from './routing';
|
||||
|
||||
export default getRequestConfig(async ({requestLocale}) => {
|
||||
// This typically corresponds to the `[locale]` segment
|
||||
let locale = await requestLocale;
|
||||
type LocaleType = (typeof routing.locales)[number];
|
||||
|
||||
// Ensure that a valid locale is used
|
||||
if (!locale || !routing.locales.includes(locale as LocaleType)) {
|
||||
locale = routing.defaultLocale;
|
||||
}
|
||||
|
||||
return {
|
||||
locale,
|
||||
messages: (await import(`../../messages/${locale}.json`)).default
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
import {createNavigation} from 'next-intl/navigation';
|
||||
import {defineRouting} from 'next-intl/routing';
|
||||
|
||||
export const routing = defineRouting({
|
||||
locales: ['en', 'de'],
|
||||
defaultLocale: 'en',
|
||||
pathnames: {
|
||||
'/': '/',
|
||||
'/pathnames': {
|
||||
en: '/pathnames',
|
||||
de: '/pfadnamen'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export type Pathnames = keyof typeof routing.pathnames;
|
||||
export type Locale = (typeof routing.locales)[number];
|
||||
|
||||
export const {Link, getPathname, redirect, usePathname, useRouter} =
|
||||
createNavigation(routing);
|
||||
Reference in New Issue
Block a user