This commit is contained in:
砂糖
2025-11-21 13:36:06 +08:00
commit 7cd50654ed
112 changed files with 14246 additions and 0 deletions

32
i18n/request.ts Normal file
View File

@@ -0,0 +1,32 @@
import { getRequestConfig } from 'next-intl/server';
import { routing } from './routing';
export default getRequestConfig(async ({ requestLocale }) => {
// This typically corresponds to the `[locale]` segment
let locale = await requestLocale;
if (locale?.startsWith('zh')) {
locale = 'zh';
} else if (locale?.startsWith('ja')) {
locale = 'ja';
} else if (locale?.startsWith('en')) {
locale = 'en';
} else if (locale?.startsWith('vi')) {
locale = 'vi';
} else {
locale = 'zh';
}
// Ensure that a valid locale is used
if (!locale || !routing.locales.includes(locale as any)) {
return {
locale: routing.defaultLocale,
messages: (await import(`./messages/${routing.defaultLocale}.json`)).default
};
}
return {
locale,
messages: (await import(`./messages/${locale}.json`)).default
};
});