添加i18n

This commit is contained in:
2025-12-18 18:32:35 +08:00
parent ebe385a624
commit cd40c603a1
17 changed files with 597 additions and 112 deletions
+16
View File
@@ -0,0 +1,16 @@
import {getRequestConfig} from 'next-intl/server';
export default getRequestConfig(async ({requestLocale}) => {
// This typically corresponds to the `[locale]` segment
let locale = await requestLocale;
// Ensure that a valid locale is used
if (!locale || !['en', 'zh', 'ja'].includes(locale)) {
locale = 'zh';
}
return {
locale,
messages: (await import(`../messages/${locale}.json`)).default
};
});
+15
View File
@@ -0,0 +1,15 @@
import {defineRouting} from 'next-intl/routing';
import {createNavigation} from 'next-intl/navigation';
export const routing = defineRouting({
// A list of all locales that are supported
locales: ['en', 'zh', 'ja'],
// Used when no locale matches
defaultLocale: 'zh'
});
// Lightweight wrappers around Next.js' navigation APIs
// that will consider the routing configuration
export const {Link, redirect, usePathname, useRouter, getPathname} =
createNavigation(routing);