init
This commit is contained in:
36
i18n/routing.ts
Normal file
36
i18n/routing.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { createNavigation } from 'next-intl/navigation';
|
||||
import { defineRouting } from 'next-intl/routing';
|
||||
|
||||
export const LOCALES = ['en', 'zh']
|
||||
export const DEFAULT_LOCALE = 'zh'
|
||||
export const LOCALE_NAMES: Record<string, string> = {
|
||||
'en': "English",
|
||||
'zh': "中文",
|
||||
// 'vi': "Tiếng Việt",
|
||||
};
|
||||
|
||||
export const routing = defineRouting({
|
||||
// A list of all locales that are supported
|
||||
locales: LOCALES,
|
||||
|
||||
// Used when no locale matches
|
||||
defaultLocale: DEFAULT_LOCALE,
|
||||
|
||||
// auto detect locale
|
||||
localeDetection: process.env.NEXT_PUBLIC_LOCALE_DETECTION === 'true',
|
||||
|
||||
localePrefix: 'always',
|
||||
});
|
||||
|
||||
// Lightweight wrappers around Next.js' navigation APIs
|
||||
// that will consider the routing configuration
|
||||
export const {
|
||||
Link,
|
||||
redirect,
|
||||
usePathname,
|
||||
useRouter,
|
||||
getPathname,
|
||||
} = createNavigation(routing);
|
||||
|
||||
|
||||
export type Locale = (typeof routing.locales)[number];
|
||||
Reference in New Issue
Block a user