This commit is contained in:
砂糖
2026-01-24 16:54:44 +08:00
commit 70f337bb92
186 changed files with 23792 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('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
};
});