Add i18n support

This commit is contained in:
2023-05-28 11:44:01 +08:00
parent 8f0ed03117
commit affe85f81c
11 changed files with 140 additions and 10 deletions

View File

@@ -1,15 +1,23 @@
import { Head } from "$fresh/runtime.ts";
import { Handlers, PageProps } from "$fresh/server.ts";
import GlobalContext from "../components/GlobalContext.tsx";
import Container from "../islands/Container.tsx";
import { get_i18nmap, i18n_handle_request } from "../server/i18ns.ts";
export default function Index() {
export const handler: Handlers<string> = {
GET(req, ctx) {
const re = i18n_handle_request(req);
if (typeof re === "string") return ctx.render(re);
return re;
},
};
export default function Index({ data }: PageProps<string>) {
const i18n = get_i18nmap(data);
return (
<body>
<GlobalContext>
<Head>
<title>EH Downloader</title>
</Head>
<Container />
<Container i18n={i18n} />
</GlobalContext>
</body>
);