first commit

This commit is contained in:
sofio
2026-02-03 15:47:03 +08:00
parent 94b39b2099
commit e87c9006a8
52 changed files with 5762 additions and 119 deletions

9
src/i18n/config.ts Normal file
View File

@@ -0,0 +1,9 @@
export const locales = ["zh", "zh-Hant", "en"] as const;
export type Locale = (typeof locales)[number];
export const defaultLocale: Locale = "zh";
export const localeNames: Record<Locale, string> = {
zh: "简",
"zh-Hant": "繁",
en: "EN",
};

5
src/i18n/navigation.ts Normal file
View File

@@ -0,0 +1,5 @@
import { createNavigation } from "next-intl/navigation";
import { routing } from "./routing";
export const { Link, redirect, usePathname, useRouter } =
createNavigation(routing);

16
src/i18n/request.ts Normal file
View File

@@ -0,0 +1,16 @@
import { getRequestConfig } from "next-intl/server";
import { routing } from "./routing";
import { Locale } from "./config";
export default getRequestConfig(async ({ requestLocale }) => {
let locale = await requestLocale;
if (!locale || !routing.locales.includes(locale as Locale)) {
locale = routing.defaultLocale;
}
return {
locale,
messages: (await import(`../messages/${locale}.json`)).default,
};
});

8
src/i18n/routing.ts Normal file
View File

@@ -0,0 +1,8 @@
import { defineRouting } from "next-intl/routing";
import { locales, defaultLocale } from "./config";
export const routing = defineRouting({
locales,
defaultLocale,
localePrefix: "as-needed",
});