mirror of
https://github.com/certimate-go/certimate.git
synced 2026-09-24 23:10:13 +08:00
fix: #1310
This commit is contained in:
Vendored
+2
-10
@@ -1,5 +1,4 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { type Locale } from "antd/es/locale";
|
||||
import AntdLocaleEnUS from "antd/locale/en_US";
|
||||
import AntdLocaleZhCN from "antd/locale/zh_CN";
|
||||
@@ -13,12 +12,5 @@ const localesMap: Record<string, Locale> = {
|
||||
|
||||
export const useAntdLocale = () => {
|
||||
const { i18n } = useTranslation();
|
||||
|
||||
const [antdLocale, setAntdLocale] = useState<Locale>(localesMap[i18n.language]);
|
||||
|
||||
useEffect(() => {
|
||||
setAntdLocale(localesMap[i18n.language]);
|
||||
}, [i18n.language]);
|
||||
|
||||
return antdLocale;
|
||||
return localesMap[i18n.resolvedLanguage ?? i18n.language];
|
||||
};
|
||||
|
||||
Vendored
+2
-7
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import dayjs from "dayjs";
|
||||
import { type Locale as ILocale } from "dayjs/locale/en";
|
||||
@@ -15,12 +15,7 @@ const localesMap: Record<string, Locale> = {
|
||||
|
||||
export const useDayjsLocale = () => {
|
||||
const { i18n } = useTranslation();
|
||||
|
||||
const [dayjsLocale, setDayjsLocale] = useState<Locale>(localesMap[i18n.language]);
|
||||
|
||||
useEffect(() => {
|
||||
setDayjsLocale(localesMap[i18n.language]);
|
||||
}, [i18n.language]);
|
||||
const dayjsLocale = localesMap[i18n.resolvedLanguage ?? i18n.language];
|
||||
|
||||
useEffect(() => {
|
||||
dayjs.locale(dayjsLocale);
|
||||
|
||||
Vendored
+2
-7
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { config as zconfig } from "zod";
|
||||
import { en as ZodLocaleEnUs, zhCN as ZodLocaleZhCN } from "zod/locales";
|
||||
@@ -89,12 +89,7 @@ const localesMap: Record<string, Locale> = {
|
||||
|
||||
export const useZodLocale = () => {
|
||||
const { i18n } = useTranslation();
|
||||
|
||||
const [zodLocale, setZodLocale] = useState<Locale>(localesMap[i18n.language]);
|
||||
|
||||
useEffect(() => {
|
||||
setZodLocale(localesMap[i18n.language]);
|
||||
}, [i18n.language]);
|
||||
const zodLocale = localesMap[i18n.resolvedLanguage ?? i18n.language];
|
||||
|
||||
useEffect(() => {
|
||||
zconfig(zodLocale);
|
||||
|
||||
Reference in New Issue
Block a user