feat: install next-intl and set up i18n routing config
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { getRequestConfig } from 'next-intl/server'
|
||||
import { routing } from './routing'
|
||||
|
||||
export default getRequestConfig(async ({ requestLocale }) => {
|
||||
let locale = await requestLocale
|
||||
if (!locale || !(routing.locales as readonly string[]).includes(locale)) {
|
||||
locale = routing.defaultLocale
|
||||
}
|
||||
return {
|
||||
locale,
|
||||
messages: (await import(`../../messages/${locale}.json`)).default,
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,6 @@
|
||||
import { defineRouting } from 'next-intl/routing'
|
||||
|
||||
export const routing = defineRouting({
|
||||
locales: ['en', 'fr', 'es', 'it'],
|
||||
defaultLocale: 'en',
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
import { createNavigation } from 'next-intl/navigation'
|
||||
import { routing } from './i18n/routing'
|
||||
|
||||
export const { Link, redirect, usePathname, useRouter } = createNavigation(routing)
|
||||
Reference in New Issue
Block a user