-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathi18n.ts
More file actions
27 lines (21 loc) · 708 Bytes
/
Copy pathi18n.ts
File metadata and controls
27 lines (21 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { notFound } from 'next/navigation'
import { getRequestConfig } from 'next-intl/server'
// Can be imported from a shared config
export const locales = ['en', 'es'] as const
export type Locale = (typeof locales)[number]
export const defaultLocale: Locale = 'en'
export const localeNames: Record<Locale, string> = {
en: 'English',
es: 'Español',
}
export default getRequestConfig(async ({ requestLocale }) => {
let locale = await requestLocale;
// Validate that the incoming `locale` parameter is valid
if (!locale || !locales.includes(locale as Locale)) {
locale = defaultLocale;
}
return {
locale,
messages: (await import(`./messages/${locale}.json`)).default,
}
})