feat: 添加组件库多语言

This commit is contained in:
gary 2022-05-09 11:24:20 +08:00
parent 0bfc695bf3
commit 91807a2e3e
2 changed files with 50 additions and 45 deletions

View File

@ -1125,5 +1125,6 @@
"possess LP": "持有LP", "possess LP": "持有LP",
"capital pool": "资金池", "capital pool": "资金池",
"Unclaimed income": "待领取收益", "Unclaimed income": "待领取收益",
"pledge": "质押" "pledge": "质押",
"Invite": "邀请"
} }

View File

@ -1,6 +1,6 @@
import React, { lazy, useEffect } from 'react' import React, { lazy, useEffect } from 'react'
import { Router, Redirect, Route, Switch } from 'react-router-dom' import { Router, Redirect, Route, Switch } from 'react-router-dom'
import { ResetCSS } from '@pancakeswap/uikit' import { ResetCSS, ConfigProvider } from '@pancakeswap/uikit'
import { useDispatch } from 'react-redux' import { useDispatch } from 'react-redux'
import BigNumber from 'bignumber.js' import BigNumber from 'bignumber.js'
import useEagerConnect from 'hooks/useEagerConnect' import useEagerConnect from 'hooks/useEagerConnect'
@ -10,6 +10,7 @@ import { initAxios } from 'utils/request'
import useToast from 'hooks/useToast' import useToast from 'hooks/useToast'
import { useAccountEventListener } from 'hooks/useAccountEventListener' import { useAccountEventListener } from 'hooks/useAccountEventListener'
import { fetchUserInfo, clearUserInfo } from 'state/actions' import { fetchUserInfo, clearUserInfo } from 'state/actions'
import { useTranslation } from 'contexts/Localization'
import { useAccount } from 'state/userInfo/hooks' import { useAccount } from 'state/userInfo/hooks'
import GlobalStyle from './style/Global' import GlobalStyle from './style/Global'
import Menu from './components/Menu' import Menu from './components/Menu'
@ -70,6 +71,7 @@ const App: React.FC = () => {
const dispatch = useDispatch() const dispatch = useDispatch()
const toast = useToast() const toast = useToast()
const account = useAccount() const account = useAccount()
const { t } = useTranslation()
useEffect(() => { useEffect(() => {
initAxios(() => { initAxios(() => {
@ -81,37 +83,38 @@ const App: React.FC = () => {
}, [account]) }, [account])
return ( return (
<Router history={history}> <ConfigProvider t={t}>
<ResetCSS /> <Router history={history}>
<GlobalStyle /> <ResetCSS />
<Menu> <GlobalStyle />
<SuspenseWithChunkError fallback={<PageLoader />}> <Menu>
<Switch> <SuspenseWithChunkError fallback={<PageLoader />}>
<Route path="/" exact> <Switch>
<Home /> <Route path="/" exact>
</Route> <Home />
<Route exact path="/farms/auction"> </Route>
<FarmAuction /> <Route exact path="/farms/auction">
</Route> <FarmAuction />
<Route path="/farms"> </Route>
<Farms /> <Route path="/farms">
</Route> <Farms />
<Route path="/pools"> </Route>
<Pools /> <Route path="/pools">
</Route> <Pools />
<Route path="/referral"> </Route>
<Referral /> <Route path="/referral">
</Route> <Referral />
<Route path="/board"> </Route>
<Board /> <Route path="/board">
</Route> <Board />
<Route path="/nft"> </Route>
<Nft /> <Route path="/nft">
</Route> <Nft />
<Route path="/announcement"> </Route>
<Announcement /> <Route path="/announcement">
</Route> <Announcement />
{/* <Route path="/lottery"> </Route>
{/* <Route path="/lottery">
<Lottery /> <Lottery />
</Route> </Route>
<Route path="/ifo"> <Route path="/ifo">
@ -146,7 +149,7 @@ const App: React.FC = () => {
</Route> </Route>
{/* Using this format because these components use routes injected props. We need to rework them with hooks */} {/* Using this format because these components use routes injected props. We need to rework them with hooks */}
{/* <Route exact strict path="/swap" component={Swap} /> {/* <Route exact strict path="/swap" component={Swap} />
<Route exact strict path="/swap/:outputCurrency" component={RedirectToSwap} /> <Route exact strict path="/swap/:outputCurrency" component={RedirectToSwap} />
<Route exact strict path="/send" component={RedirectPathToSwapOnly} /> <Route exact strict path="/send" component={RedirectPathToSwapOnly} />
<Route exact strict path="/find" component={PoolFinder} /> <Route exact strict path="/find" component={PoolFinder} />
@ -163,8 +166,8 @@ const App: React.FC = () => {
<Route exact strict path="/nft" component={Nft} /> <Route exact strict path="/nft" component={Nft} />
<Route exact strict path="/announcement" component={Announcement} /> */} <Route exact strict path="/announcement" component={Announcement} /> */}
{/* Redirect */} {/* Redirect */}
{/* <Route path="/staking"> {/* <Route path="/staking">
<Redirect to="/pools" /> <Redirect to="/pools" />
</Route> </Route>
<Route path="/syrup"> <Route path="/syrup">
@ -174,15 +177,16 @@ const App: React.FC = () => {
<Redirect to="/collectibles" /> <Redirect to="/collectibles" />
</Route> */} </Route> */}
{/* 404 */} {/* 404 */}
<Route component={NotFound} /> <Route component={NotFound} />
</Switch> </Switch>
</SuspenseWithChunkError> </SuspenseWithChunkError>
</Menu> </Menu>
<EasterEgg iterations={2} /> <EasterEgg iterations={2} />
<ToastListener /> <ToastListener />
<DatePickerPortal /> <DatePickerPortal />
</Router> </Router>
</ConfigProvider>
) )
} }