Skip to content

Commit

Permalink
feat(site): component Internationalization (#3100)
Browse files Browse the repository at this point in the history
* feat(site): component Internationalization

* fix: 使用`tdesign-site-components` 提供函数设置 international

* chore: remove `document.addEventListener`
style: add useEffect dependency

* chore: reset settings

* chore: fix

* chore: remove

---------

Co-authored-by: wū yāng <[email protected]>
  • Loading branch information
RSS1102 and uyarn authored Sep 19, 2024
1 parent d41a2db commit 1d39aea
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions site/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import React, { useEffect, useRef, useState, lazy, Suspense } from 'react';
import { BrowserRouter, Routes, Navigate, Route, useLocation, useNavigate, Outlet } from 'react-router-dom';
import Loading from 'tdesign-react/loading';
import ConfigProvider from 'tdesign-react/config-provider';
// import locale from 'tdesign-react/locale/zh_CN';
// import locale from 'tdesign-react/locale/en_US';
import zhConfig from 'tdesign-react/es/locale/zh_CN';
import enConfig from 'tdesign-react/es/locale/en_US';
import { getLang } from 'tdesign-site-components';

import siteConfig from '../site.config';
import { getRoute, filterVersions } from './utils';
import packageJson from '@/package.json';
Expand Down Expand Up @@ -48,6 +50,7 @@ function Components() {
const tdDocSearch = useRef();

const [version] = useState(currentVersion);
const [globalConfig] = useState(getLang() === 'en' ? enConfig : zhConfig);

function initHistoryVersions() {
fetch(registryUrl)
Expand Down Expand Up @@ -92,14 +95,15 @@ function Components() {
};

initHistoryVersions();

}, []);

useEffect(() => {
document.querySelector('td-stats')?.track?.();
}, [location]);

return (
<ConfigProvider /* globalConfig={{ animation: { exclude: ['ripple'] }}} */>
<ConfigProvider globalConfig={globalConfig}>
<td-doc-layout>
<td-header ref={tdHeaderRef} slot="header">
<td-doc-search slot="search" ref={tdDocSearch} />
Expand Down

0 comments on commit 1d39aea

Please sign in to comment.