Skip to content

Commit 04d5ec7

Browse files
authored
feat/multi language widget (#2847)
* Try add lingui widget Continue setup Add gitignore Complete setup POC Update build script * Add translate * Try fix build * Add lingui liquidity widgets * Update message * Show language switch * Setup lingui zap-in * Setup lingui zap-migration * Fix translate ERROR_MESSAGE * Translate zap out Auto stash before rebase of "feat/multi-language-widget" * Translate zap-migration-widgets Fix conflict Remove duplidated PoolInfo * Update * Update * Update * Hide switch languague * Revert "Hide switch languague" This reverts commit cec3034. * Update * Hide switch languague
1 parent 9547c78 commit 04d5ec7

File tree

140 files changed

+5554
-883
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+5554
-883
lines changed

apps/kyberswap-interface/src/components/SwapForm/SwapModal/SwapDetails/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ChainId, Currency, CurrencyAmount } from '@kyberswap/ks-sdk-core'
2-
import { Trans } from '@lingui/macro'
2+
import { Trans, t } from '@lingui/macro'
33
import { rgba } from 'polished'
44
import { useCallback, useState } from 'react'
55
import { isMobile, isTablet } from 'react-device-detect'
@@ -234,7 +234,7 @@ export default function SwapDetails({ isLoading, gasUsd, minimumAmountOut, price
234234
<RowFixed>
235235
<TextDashed fontSize={12} fontWeight={400} color={theme.subText}>
236236
<MouseoverTooltip text={<Trans>Estimated network fee for your transaction.</Trans>} placement="right">
237-
{paymentToken ? 'Est. Paymaster Gas Fee' : 'Estimated Total Gas'}
237+
{paymentToken ? t`Est. Paymaster Gas Fee` : t`Estimated Total Gas`}
238238
</MouseoverTooltip>
239239
</TextDashed>
240240
</RowFixed>

apps/kyberswap-interface/src/locales/en-US.po

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,10 @@ msgstr "Cross-Chain Routing Sources"
737737
msgid "Are you sure you want to cancel {0} limit orders?"
738738
msgstr "Are you sure you want to cancel {0} limit orders?"
739739

740+
#: src/components/SwapForm/SwapModal/SwapDetails/index.tsx
741+
msgid "Est. Paymaster Gas Fee"
742+
msgstr "Est. Paymaster Gas Fee"
743+
740744
#: src/components/Announcement/Popups/TransactionPopup.tsx
741745
msgid "You have successfully transferred {postFix}"
742746
msgstr "You have successfully transferred {postFix}"
@@ -1474,6 +1478,7 @@ msgstr "Active Alerts"
14741478
msgid "Your trade is routed through one of these cross-chain sources."
14751479
msgstr "Your trade is routed through one of these cross-chain sources."
14761480

1481+
#: src/pages/Earns/components/ClaimModal/index.tsx
14771482
#: src/pages/Earns/UserPositions/DropdownAction.tsx
14781483
msgid "Claim Fees"
14791484
msgstr "Claim Fees"
@@ -3264,6 +3269,10 @@ msgstr "Your slippage {msg}"
32643269
msgid "Selecting Treasury Grant Option"
32653270
msgstr "Selecting Treasury Grant Option"
32663271

3272+
#: src/pages/Earns/UserPositions/Filter.tsx
3273+
msgid "Closed Positions"
3274+
msgstr "Closed Positions"
3275+
32673276
#: src/components/ReadMore/index.tsx
32683277
msgid "Read more"
32693278
msgstr "Read more"
@@ -3418,6 +3427,10 @@ msgstr "Order will Expire on"
34183427
msgid "High APR"
34193428
msgstr "High APR"
34203429

3430+
#: src/pages/Earns/UserPositions/Filter.tsx
3431+
msgid "Out Range"
3432+
msgstr "Out Range"
3433+
34213434
#: src/components/ClassicElasticTab.tsx
34223435
#: src/components/ClassicElasticTab.tsx
34233436
#: src/components/ClassicElasticTab.tsx
@@ -3564,10 +3577,6 @@ msgstr "Remove from favorites"
35643577
msgid "Select a token"
35653578
msgstr "Select a token"
35663579

3567-
#: src/pages/Earns/components/ClaimModal/index.tsx
3568-
msgid "Claim {claimType}"
3569-
msgstr "Claim {claimType}"
3570-
35713580
#: src/pages/Campaign/components/Information.tsx
35723581
msgid "How to earn points"
35733582
msgstr "How to earn points"
@@ -4450,6 +4459,10 @@ msgstr "View Pools"
44504459
msgid "Search proposals"
44514460
msgstr "Search proposals"
44524461

4462+
#: src/pages/Earns/UserPositions/Filter.tsx
4463+
msgid "In Range"
4464+
msgstr "In Range"
4465+
44534466
#: src/components/Badge/RangeBadge.tsx
44544467
msgid "The price of this pool is within your selected range. Your position is currently earning fees."
44554468
msgstr "The price of this pool is within your selected range. Your position is currently earning fees."
@@ -4839,6 +4852,10 @@ msgstr "STATUS"
48394852
msgid "Amount to remove"
48404853
msgstr "Amount to remove"
48414854

4855+
#: src/pages/Earns/PositionDetail/index.tsx
4856+
msgid "APR calculated based on last {aprInterval} fees. Useful for recent performance trends."
4857+
msgstr "APR calculated based on last {aprInterval} fees. Useful for recent performance trends."
4858+
48424859
#: src/pages/Earns/PositionDetail/LeftSection.tsx
48434860
msgid "Unclaimed Fees"
48444861
msgstr "Unclaimed Fees"
@@ -5366,6 +5383,7 @@ msgstr "Only trading volume from pairs composed of <0>eligible tokens</0> will b
53665383
#: src/pages/Campaign/MyDashboard.tsx
53675384
#: src/pages/Campaign/MyDashboard.tsx
53685385
#: src/pages/Earns/components/ClaimAllModal/index.tsx
5386+
#: src/pages/Earns/components/ClaimModal/index.tsx
53695387
#: src/pages/Earns/PositionDetail/LeftSection.tsx
53705388
#: src/pages/Earns/PositionDetail/RewardSection.tsx
53715389
#: src/pages/Earns/UserPositions/PositionBanner.tsx
@@ -5808,6 +5826,10 @@ msgstr "One token is close to 0% in the pool ratio. Pool might go inactive."
58085826
msgid "Invalid recipient"
58095827
msgstr "Invalid recipient"
58105828

5829+
#: src/components/SwapForm/SwapModal/SwapDetails/index.tsx
5830+
msgid "Estimated Total Gas"
5831+
msgstr "Estimated Total Gas"
5832+
58115833
#: src/pages/KyberDAO/KNCUtility/GasRefundBox.tsx
58125834
msgid "Total Gas Refund"
58135835
msgstr "Total Gas Refund"
@@ -7567,6 +7589,7 @@ msgstr "Total Points: Combined points from all participants"
75677589

75687590
#: src/components/Menu/index.tsx
75697591
#: src/pages/Earns/components/ClaimAllModal/index.tsx
7592+
#: src/pages/Earns/components/ClaimModal/index.tsx
75707593
#: src/pages/Earns/UserPositions/DropdownAction.tsx
75717594
#: src/pages/ElasticLegacy/FarmLegacy.tsx
75727595
msgid "Claim Rewards"

apps/kyberswap-interface/src/locales/zh-CN.po

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,10 @@ msgstr "跨链路由来源"
737737
msgid "Are you sure you want to cancel {0} limit orders?"
738738
msgstr "您确定要取消 {0} 笔限价订单吗?"
739739

740+
#: src/components/SwapForm/SwapModal/SwapDetails/index.tsx
741+
msgid "Est. Paymaster Gas Fee"
742+
msgstr "预计 Paymaster Gas 费用"
743+
740744
#: src/components/Announcement/Popups/TransactionPopup.tsx
741745
msgid "You have successfully transferred {postFix}"
742746
msgstr "您已成功转账 {postFix}"
@@ -1474,6 +1478,7 @@ msgstr "进行中的提醒"
14741478
msgid "Your trade is routed through one of these cross-chain sources."
14751479
msgstr "您的交易将通过上述跨链来源之一路由。"
14761480

1481+
#: src/pages/Earns/components/ClaimModal/index.tsx
14771482
#: src/pages/Earns/UserPositions/DropdownAction.tsx
14781483
msgid "Claim Fees"
14791484
msgstr "领取手续费"
@@ -3264,6 +3269,10 @@ msgstr "您的滑点{msg}"
32643269
msgid "Selecting Treasury Grant Option"
32653270
msgstr "选择国库资助选项"
32663271

3272+
#: src/pages/Earns/UserPositions/Filter.tsx
3273+
msgid "Closed Positions"
3274+
msgstr "已关闭仓位"
3275+
32673276
#: src/components/ReadMore/index.tsx
32683277
msgid "Read more"
32693278
msgstr "阅读更多"
@@ -3418,6 +3427,10 @@ msgstr "订单将于以下时间过期"
34183427
msgid "High APR"
34193428
msgstr "高年化收益率"
34203429

3430+
#: src/pages/Earns/UserPositions/Filter.tsx
3431+
msgid "Out Range"
3432+
msgstr "范围外"
3433+
34213434
#: src/components/ClassicElasticTab.tsx
34223435
#: src/components/ClassicElasticTab.tsx
34233436
#: src/components/ClassicElasticTab.tsx
@@ -3564,10 +3577,6 @@ msgstr "从收藏中移除"
35643577
msgid "Select a token"
35653578
msgstr "选择一个代币"
35663579

3567-
#: src/pages/Earns/components/ClaimModal/index.tsx
3568-
msgid "Claim {claimType}"
3569-
msgstr "领取 {claimType}"
3570-
35713580
#: src/pages/Campaign/components/Information.tsx
35723581
msgid "How to earn points"
35733582
msgstr "如何获取积分"
@@ -4450,6 +4459,10 @@ msgstr "查看资金池"
44504459
msgid "Search proposals"
44514460
msgstr "搜索提案"
44524461

4462+
#: src/pages/Earns/UserPositions/Filter.tsx
4463+
msgid "In Range"
4464+
msgstr "范围内"
4465+
44534466
#: src/components/Badge/RangeBadge.tsx
44544467
msgid "The price of this pool is within your selected range. Your position is currently earning fees."
44554468
msgstr "该资金池的价格位于您选择的区间内,您的仓位当前正在赚取手续费。"
@@ -4839,6 +4852,10 @@ msgstr "状态"
48394852
msgid "Amount to remove"
48404853
msgstr "移除数量"
48414854

4855+
#: src/pages/Earns/PositionDetail/index.tsx
4856+
msgid "APR calculated based on last {aprInterval} fees. Useful for recent performance trends."
4857+
msgstr "APR 基于最近 {aprInterval} 的手续费计算,可用于参考近期表现趋势。"
4858+
48424859
#: src/pages/Earns/PositionDetail/LeftSection.tsx
48434860
msgid "Unclaimed Fees"
48444861
msgstr "未领取的手续费"
@@ -5366,6 +5383,7 @@ msgstr "仅统计由<0>合资格代币</0>组成的交易对的交易量,WETH-
53665383
#: src/pages/Campaign/MyDashboard.tsx
53675384
#: src/pages/Campaign/MyDashboard.tsx
53685385
#: src/pages/Earns/components/ClaimAllModal/index.tsx
5386+
#: src/pages/Earns/components/ClaimModal/index.tsx
53695387
#: src/pages/Earns/PositionDetail/LeftSection.tsx
53705388
#: src/pages/Earns/PositionDetail/RewardSection.tsx
53715389
#: src/pages/Earns/UserPositions/PositionBanner.tsx
@@ -5808,6 +5826,10 @@ msgstr "一个代币在池中的比例接近0%时,池可能会变得不活跃
58085826
msgid "Invalid recipient"
58095827
msgstr "收件人无效"
58105828

5829+
#: src/components/SwapForm/SwapModal/SwapDetails/index.tsx
5830+
msgid "Estimated Total Gas"
5831+
msgstr "预计总 Gas 费用"
5832+
58115833
#: src/pages/KyberDAO/KNCUtility/GasRefundBox.tsx
58125834
msgid "Total Gas Refund"
58135835
msgstr "Gas 返还总额"
@@ -7567,6 +7589,7 @@ msgstr "总代积分:所有参与者的积分总和"
75677589

75687590
#: src/components/Menu/index.tsx
75697591
#: src/pages/Earns/components/ClaimAllModal/index.tsx
7592+
#: src/pages/Earns/components/ClaimModal/index.tsx
75707593
#: src/pages/Earns/UserPositions/DropdownAction.tsx
75717594
#: src/pages/ElasticLegacy/FarmLegacy.tsx
75727595
msgid "Claim Rewards"

apps/kyberswap-interface/src/pages/Earns/PositionDetail/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ const PositionDetail = () => {
419419
<DropdownMenu
420420
width={30}
421421
flatten
422-
tooltip={`APR calculated based on last ${aprInterval} fees. Useful for recent performance trends.`}
422+
tooltip={t`APR calculated based on last ${aprInterval} fees. Useful for recent performance trends.`}
423423
options={timings.slice(0, 2)}
424424
value={aprInterval}
425425
alignLeft

apps/kyberswap-interface/src/pages/Earns/UserPositions/Filter.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { t } from '@lingui/macro'
1+
import { Trans, t } from '@lingui/macro'
22
import { useEffect, useState } from 'react'
33
import { useSearchParams } from 'react-router-dom'
44
import { useMedia } from 'react-use'
@@ -13,9 +13,9 @@ import { PositionFilter, PositionStatus } from 'pages/Earns/types'
1313
import { MEDIA_WIDTHS } from 'theme'
1414

1515
const POSITION_STATUS = [
16-
{ label: 'In Range', value: PositionStatus.IN_RANGE },
17-
{ label: 'Out Range', value: PositionStatus.OUT_RANGE },
18-
{ label: 'Closed Positions', value: PositionStatus.CLOSED },
16+
{ label: <Trans>In Range</Trans>, value: PositionStatus.IN_RANGE },
17+
{ label: <Trans>Out Range</Trans>, value: PositionStatus.OUT_RANGE },
18+
{ label: <Trans>Closed Positions</Trans>, value: PositionStatus.CLOSED },
1919
]
2020

2121
export default function Filter({
@@ -78,7 +78,7 @@ export default function Filter({
7878
alignLeft
7979
mobileFullWidth
8080
label={t`Position status`}
81-
options={POSITION_STATUS}
81+
options={POSITION_STATUS as unknown as MenuOption[]}
8282
value={filters.status || ''}
8383
onChange={value => value !== filters.status && updateFilters('status', value)}
8484
/>

apps/kyberswap-interface/src/pages/Earns/components/ClaimModal/index.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,18 @@ const ClaimModal = ({
9797
<Wrapper>
9898
<ModalHeader>
9999
<Text fontSize={20} fontWeight={500}>
100-
{t`Claim ${claimType}`}
100+
{claimType === ClaimType.FEES
101+
? t`Claim Fees`
102+
: claimType === ClaimType.REWARDS
103+
? t`Claim Rewards`
104+
: t`Claim`}
101105
</Text>
102106
<X onClick={onClose} />
103107
</ModalHeader>
104108
<ClaimInfoWrapper>
105-
<Text
106-
fontSize={14}
107-
color={theme.subText}
108-
marginBottom={2}
109-
>{t`Choose to reinvest your earnings back into this position or send them to your wallet.`}</Text>
109+
<Text fontSize={14} color={theme.subText} marginBottom={2}>
110+
{t`Choose to reinvest your earnings back into this position or send them to your wallet.`}
111+
</Text>
110112
<ClaimInfo>
111113
<Flex alignItems={'center'} justifyContent={'space-between'}>
112114
<Text fontSize={14} color={theme.subText}>{t`Total Value`}</Text>

apps/kyberswap-interface/src/pages/Earns/hooks/useCompounding.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
ChainId as CompoundingChainId,
33
PoolType as CompoundingPoolType,
44
CompoundingWidget,
5+
SupportedLocale,
56
TxStatus,
67
} from '@kyberswap/compounding-widget'
78
import '@kyberswap/compounding-widget/dist/style.css'
@@ -12,6 +13,7 @@ import { useNavigate } from 'react-router-dom'
1213
import { NotificationType } from 'components/Announcement/type'
1314
import Modal from 'components/Modal'
1415
import { useActiveWeb3React, useWeb3React } from 'hooks'
16+
import { useActiveLocale } from 'hooks/useActiveLocale'
1517
import { useChangeNetwork } from 'hooks/web3/useChangeNetwork'
1618
import { EARN_DEXES, Exchange } from 'pages/Earns/constants'
1719
import useAccountChanged from 'pages/Earns/hooks/useAccountChanged'
@@ -33,6 +35,7 @@ interface CompoundingPureParams {
3335

3436
interface CompoundingParams extends CompoundingPureParams {
3537
rpcUrl?: string
38+
locale?: SupportedLocale
3639
connectedAccount: {
3740
address?: string | undefined
3841
chainId: number
@@ -78,6 +81,7 @@ const useCompounding = ({
7881
onRefreshPosition?: () => void
7982
onCloseClaimModal: () => void
8083
}) => {
84+
const locale = useActiveLocale()
8185
const addTransactionWithType = useTransactionAdder()
8286
const allTransactions = useAllTransactions()
8387
const toggleWalletModal = useWalletModalToggle()
@@ -158,6 +162,7 @@ const useCompounding = ({
158162
? {
159163
...compoundingPureParams,
160164
rpcUrl: compoundingRpcUrl,
165+
locale,
161166
connectedAccount: {
162167
address: account,
163168
chainId: chainId,
@@ -228,6 +233,7 @@ const useCompounding = ({
228233
compoundingRpcUrl,
229234
handleCloseCompounding,
230235
handleNavigateToPosition,
236+
locale,
231237
library,
232238
onRefreshPosition,
233239
toggleWalletModal,

apps/kyberswap-interface/src/pages/Earns/hooks/useZapInWidget.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ChainId } from '@kyberswap/ks-sdk-core'
22
import {
33
OnSuccessProps,
4+
SupportedLocale,
45
TxStatus,
56
LiquidityWidget as ZapIn,
67
ChainId as ZapInChainId,
@@ -14,6 +15,7 @@ import { NotificationType } from 'components/Announcement/type'
1415
import Modal from 'components/Modal'
1516
import { NETWORKS_INFO } from 'constants/networks'
1617
import { useActiveWeb3React, useWeb3React } from 'hooks'
18+
import { useActiveLocale } from 'hooks/useActiveLocale'
1719
import { useChangeNetwork } from 'hooks/web3/useChangeNetwork'
1820
import { EARN_DEXES, Exchange } from 'pages/Earns/constants'
1921
import { CoreProtocol } from 'pages/Earns/constants/coreProtocol'
@@ -44,6 +46,7 @@ interface AddLiquidityParams extends AddLiquidityPureParams {
4446
address?: string | undefined
4547
chainId: number
4648
}
49+
locale?: SupportedLocale
4750
onClose: () => void
4851
onConnectWallet: () => void
4952
onSwitchChain: () => void
@@ -100,6 +103,7 @@ const useZapInWidget = ({
100103
triggerClose?: boolean
101104
setTriggerClose?: (value: boolean) => void
102105
}) => {
106+
const locale = useActiveLocale()
103107
const addTransactionWithType = useTransactionAdder()
104108
const allTransactions = useAllTransactions()
105109
const toggleWalletModal = useWalletModalToggle()
@@ -208,6 +212,7 @@ const useZapInWidget = ({
208212
rpcUrl: zapInRpcUrl,
209213
referral: refCode,
210214
zapStatus,
215+
locale,
211216
onViewPosition: (txHash: string) => {
212217
const { chainId, poolType, poolAddress } = addLiquidityPureParams
213218
handleCloseZapInWidget()
@@ -344,6 +349,7 @@ const useZapInWidget = ({
344349
changeNetwork,
345350
library,
346351
addTransactionWithType,
352+
locale,
347353
],
348354
)
349355

0 commit comments

Comments
 (0)