mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 16:06:28 +08:00
docs: change lang by lang (#38943)
This commit is contained in:
parent
0c3ba124b4
commit
3d0a269c81
@ -1,4 +1,4 @@
|
||||
import React, { type FC, useLayoutEffect } from 'react';
|
||||
import React, { type FC } from 'react';
|
||||
import { useLocale as useDumiLocale } from 'dumi';
|
||||
import { css } from '@emotion/react';
|
||||
import useLocale from '../../hooks/useLocale';
|
||||
@ -11,8 +11,6 @@ import BannerRecommends from './components/BannerRecommends';
|
||||
import ComponentsList from './components/ComponentsList';
|
||||
import DesignFramework from './components/DesignFramework';
|
||||
import { ConfigProvider } from 'antd';
|
||||
import dayjs from 'dayjs';
|
||||
import 'dayjs/locale/zh-cn';
|
||||
|
||||
const useStyle = () => {
|
||||
const { token } = useSiteToken();
|
||||
@ -45,7 +43,7 @@ const locales = {
|
||||
};
|
||||
|
||||
const Homepage: FC = () => {
|
||||
const [locale, lang] = useLocale(locales);
|
||||
const [locale] = useLocale(locales);
|
||||
const { id: localeId } = useDumiLocale();
|
||||
const localeStr = localeId === 'zh-CN' ? 'cn' : 'en';
|
||||
|
||||
@ -53,14 +51,6 @@ const Homepage: FC = () => {
|
||||
|
||||
const style = useStyle();
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (lang === 'cn') {
|
||||
dayjs.locale('zh-cn');
|
||||
} else {
|
||||
dayjs.locale('en');
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<ConfigProvider theme={{ algorithm: undefined }}>
|
||||
<section>
|
||||
|
@ -1,4 +1,6 @@
|
||||
import React, { type FC, useEffect, useMemo, useRef } from 'react';
|
||||
import React, { type FC, useEffect, useMemo, useRef, useLayoutEffect } from 'react';
|
||||
import 'dayjs/locale/zh-cn';
|
||||
import dayjs from 'dayjs';
|
||||
import { useOutlet, useSearchParams, Helmet } from 'dumi';
|
||||
import Header from 'dumi/theme/slots/Header';
|
||||
import Footer from 'dumi/theme/slots/Footer';
|
||||
@ -52,6 +54,14 @@ const DocLayout: FC = () => {
|
||||
setIsMobile(window.innerWidth < RESPONSIVE_MOBILE);
|
||||
};
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (lang === 'cn') {
|
||||
dayjs.locale('zh-cn');
|
||||
} else {
|
||||
dayjs.locale('en');
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const nprogressHiddenStyle = document.getElementById('nprogress-style');
|
||||
if (nprogressHiddenStyle) {
|
||||
|
Loading…
Reference in New Issue
Block a user