-
Notifications
You must be signed in to change notification settings - Fork 1
/
i18n.ts
33 lines (24 loc) · 1000 Bytes
/
i18n.ts
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
28
29
30
31
32
33
import { notFound } from 'next/navigation';
import { getRequestConfig } from 'next-intl/server';
enum LocalePrefixes {
ALWAYS = 'always',
NEVER = 'never',
ASNEEDED = 'as-needed', // removes prefix on default locale
}
const locales = ['en'] as const;
type LocalePrefixesType = `${LocalePrefixes}`;
// Temporary we use NEVER prefix to prioritize accept-language header
// & disable internationalized routes due to incomplete multilingual implementation
const localePrefix: LocalePrefixesType = LocalePrefixes.NEVER;
const defaultLocale = 'en';
type LocaleType = (typeof locales)[number];
export default getRequestConfig(async (params) => {
let lang = params.locale as LocaleType // eslint-disable-line
if (!locales.includes(lang)) notFound();
return {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
messages: await import(`./messages/${lang}.json`),
};
});
export { LocalePrefixes, locales, localePrefix, defaultLocale };
export type { LocaleType };