feat: dayjs i18n

This commit is contained in:
GyDi 2022-03-18 14:45:24 +08:00 committed by GitHub
parent 5b886fe6be
commit ed3fc50858
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,6 @@
import dayjs from "dayjs";
import i18next from "i18next";
import relativeTime from "dayjs/plugin/relativeTime";
import useSWR, { SWRConfig, useSWRConfig } from "swr";
import { useEffect, useMemo } from "react";
import { useTranslation } from "react-i18next";
@ -14,7 +16,9 @@ import LayoutItem from "../components/layout/layout-item";
import LayoutControl from "../components/layout/layout-control";
import LayoutTraffic from "../components/layout/layout-traffic";
import UpdateButton from "../components/layout/update-button";
import "dayjs/locale/zh-cn";
dayjs.extend(relativeTime);
const isMacos = navigator.userAgent.includes("Mac OS X");
const Layout = () => {
@ -40,6 +44,7 @@ const Layout = () => {
useEffect(() => {
if (data?.language) {
dayjs.locale(data.language === "zh" ? "zh-cn" : data.language);
i18next.changeLanguage(data.language);
}
}, [data?.language]);