From 2573950ad82140a16d1d8d6c48d33fcfc269d81e Mon Sep 17 00:00:00 2001 From: liuweiqing Date: Mon, 12 Feb 2024 21:35:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20i18n=20=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/[lng]/page.tsx | 10 +++++++--- components/Footer/FooterBase.js | 25 +++++++++++++++++++++++++ components/Footer/client.js | 0 components/Footer/index.js | 25 +++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 components/Footer/FooterBase.js create mode 100644 components/Footer/client.js create mode 100644 components/Footer/index.js diff --git a/app/[lng]/page.tsx b/app/[lng]/page.tsx index 585a36f..ce92435 100644 --- a/app/[lng]/page.tsx +++ b/app/[lng]/page.tsx @@ -12,6 +12,7 @@ import SettingsLink from "@/components/SettingsLink"; import PaperManagementWrapper from "@/components/PaperManagementWrapper"; //i18n import { useTranslation } from "@/app/i18n"; +import { FooterBase } from "@/components/Footer/FooterBase"; import { IndexProps } from "@/utils/global"; // import Error from "@/app/global-error"; @@ -47,16 +48,19 @@ export default async function Index({ params: { lng } }: IndexProps) { ); diff --git a/components/Footer/FooterBase.js b/components/Footer/FooterBase.js new file mode 100644 index 0000000..cf100c8 --- /dev/null +++ b/components/Footer/FooterBase.js @@ -0,0 +1,25 @@ +import Link from "next/link"; +import { Trans } from "react-i18next/TransWithoutContext"; +import { languages } from "@/app/i18n/settings"; + +export const FooterBase = ({ t, lng }) => { + return ( +
+ {/*
*/} + + Language Manager:Switch from {{ lng }} to:{" "} + + {languages + .filter((l) => lng !== l) + .map((l, index) => { + return ( + + {index > 0 && " or "} + {l} + + ); + })} + {/*
*/} +
+ ); +}; diff --git a/components/Footer/client.js b/components/Footer/client.js new file mode 100644 index 0000000..e69de29 diff --git a/components/Footer/index.js b/components/Footer/index.js new file mode 100644 index 0000000..af332f1 --- /dev/null +++ b/components/Footer/index.js @@ -0,0 +1,25 @@ +import Link from "next/link"; +import { Trans } from "react-i18next/TransWithoutContext"; +import { languages } from "../../../i18n/settings"; +import { useTranslation } from "../../../i18n"; + +export const Footer = async ({ lng }) => { + const { t } = await useTranslation(lng, "footer"); + return ( + + ); +};