diff --git a/libs/i18n/src/locales/en/withdraws.json b/libs/i18n/src/locales/en/withdraws.json new file mode 100644 index 000000000..0c8d12fd0 --- /dev/null +++ b/libs/i18n/src/locales/en/withdraws.json @@ -0,0 +1,49 @@ +{ + "All {{symbol}} withdrawals are subject to a {{delay}} delay.": "All {{symbol}} withdrawals are subject to a {{delay}} delay.", + "Amount": "Amount", + "Asset": "Asset", + "Available to withdraw in {{availableTimestamp}}": "Available to withdraw in {{availableTimestamp}}", + "Balance available": "Balance available", + "Complete the withdrawal to release your funds": "Complete the withdrawal to release your funds", + "Complete these {{count}} withdrawals to release your funds": "Complete these {{count}} withdrawals to release your funds", + "Complete withdrawal": "Complete withdrawal", + "Completed": "Completed", + "Connect Ethereum wallet to complete": "Connect Ethereum wallet to complete", + "Connect": "Connect", + "Created": "Created", + "Delay time": "Delay time", + "Delayed (ready in {{readyIn}})": "Delayed (ready in {{readyIn}})", + "Delayed withdrawal threshold": "Delayed withdrawal threshold", + "Disconnect": "Disconnect", + "Failed": "Failed", + "Insufficient amount in account": "Insufficient amount in account", + "Invalid asset source: {{source}}": "Invalid asset source: {{source}}", + "No withdrawals": "No withdrawals", + "None": "None", + "Pending": "Pending", + "Please select an asset": "Please select an asset", + "Read more": "Read more", + "Ready to complete": "Ready to complete", + "Recipient": "Recipient", + "Rejected": "Rejected", + "Release funds": "Release funds", + "Status": "Status", + "Step 1 - Release funds from Vega": "Step 1 - Release funds from Vega", + "Step 2 - Transfer funds to your Ethereum wallet": "Step 2 - Transfer funds to your Ethereum wallet", + "There are two steps required to make a withdrawal": "There are two steps required to make a withdrawal", + "This app only works on {{chainName}}. Please change chain.": "This app only works on {{chainName}}. Please change chain.", + "To (Ethereum address)": "To (Ethereum address)", + "Transaction": "Transaction", + "Use maximum": "Use maximum", + "Verifying withdrawal approval": "Verifying withdrawal approval", + "View withdrawal details": "View withdrawal details", + "View withdrawals": "View withdrawals", + "Withdraw {{amount}} {{symbol}}": "Withdraw {{amount}} {{symbol}}", + "Withdraw funds": "Withdraw funds", + "Withdraw": "Withdraw", + "Withdrawal ready": "Withdrawal ready", + "Withdrawals of {{threshold}} {{symbol}} or more will be delayed for {{delay}}.": "Withdrawals of {{threshold}} {{symbol}} or more will be delayed for {{delay}}.", + "Withdrawals ready": "Withdrawals ready", + "You have no assets to withdraw": "You have no assets to withdraw", + "Your funds have been unlocked for withdrawal - <0>View in block explorer<0>": "Your funds have been unlocked for withdrawal - <0>View in block explorer<0>" +} diff --git a/libs/withdraws/__mocks__/react-i18next.ts b/libs/withdraws/__mocks__/react-i18next.ts new file mode 100644 index 000000000..7c2343f52 --- /dev/null +++ b/libs/withdraws/__mocks__/react-i18next.ts @@ -0,0 +1,14 @@ +export const useTranslation = () => ({ + t: (label: string, replacements?: Record) => { + let translatedLabel = label; + if (typeof replacements === 'object' && replacements !== null) { + Object.keys(replacements).forEach((key) => { + translatedLabel = translatedLabel.replace( + `{{${key}}}`, + replacements[key] + ); + }); + } + return translatedLabel; + }, +}); diff --git a/libs/withdraws/src/lib/create-withdrawal-dialog.tsx b/libs/withdraws/src/lib/create-withdrawal-dialog.tsx index 33e81fb9f..d78b8588c 100644 --- a/libs/withdraws/src/lib/create-withdrawal-dialog.tsx +++ b/libs/withdraws/src/lib/create-withdrawal-dialog.tsx @@ -1,12 +1,13 @@ -import { t } from '@vegaprotocol/i18n'; import { Dialog } from '@vegaprotocol/ui-toolkit'; import { useVegaWallet } from '@vegaprotocol/wallet'; import { WithdrawFormContainer } from './withdraw-form-container'; import { useWeb3ConnectStore } from '@vegaprotocol/web3'; import { useWithdrawalDialog } from './withdrawal-dialog'; import { useVegaTransactionStore } from '@vegaprotocol/web3'; +import { useT } from './use-t'; export const CreateWithdrawalDialog = () => { + const t = useT(); const { assetId, isOpen, open, close } = useWithdrawalDialog(); const { pubKey } = useVegaWallet(); const createTransaction = useVegaTransactionStore((state) => state.create); diff --git a/libs/withdraws/src/lib/use-ready-to-complete-withdrawals-toast.tsx b/libs/withdraws/src/lib/use-ready-to-complete-withdrawals-toast.tsx index ce7942101..36c411139 100644 --- a/libs/withdraws/src/lib/use-ready-to-complete-withdrawals-toast.tsx +++ b/libs/withdraws/src/lib/use-ready-to-complete-withdrawals-toast.tsx @@ -5,7 +5,6 @@ import type { Toast } from '@vegaprotocol/ui-toolkit'; import { Button, Intent, Panel, ToastHeading } from '@vegaprotocol/ui-toolkit'; import { useToasts } from '@vegaprotocol/ui-toolkit'; import { useCallback, useEffect, useMemo, useState } from 'react'; -import { t } from '@vegaprotocol/i18n'; import { formatNumber, toBigNum } from '@vegaprotocol/utils'; import { useNavigate } from 'react-router-dom'; import { @@ -17,6 +16,7 @@ import { import { withdrawalProvider } from './withdrawals-provider'; import type { WithdrawalFieldsFragment } from './__generated__/Withdrawal'; import uniqBy from 'lodash/uniqBy'; +import { useT } from './use-t'; const CHECK_INTERVAL = 1000; const ON_APP_START_TOAST_ID = `ready-to-withdraw`; @@ -199,15 +199,15 @@ const MultipleReadyToWithdrawToastContent = ({ count: number; withdrawalsLink?: string; }) => { + const t = useT(); const navigate = useNavigate(); return ( <> {t('Withdrawals ready')}

- {t( - 'Complete these %s withdrawals to release your funds', - count.toString() - )} + {t('Complete these {{count}} withdrawals to release your funds', { + count, + })}

diff --git a/libs/withdraws/src/lib/withdrawals-table.tsx b/libs/withdraws/src/lib/withdrawals-table.tsx index b37a55db6..0c887cb04 100644 --- a/libs/withdraws/src/lib/withdrawals-table.tsx +++ b/libs/withdraws/src/lib/withdrawals-table.tsx @@ -7,7 +7,6 @@ import { isNumeric, truncateByChars, } from '@vegaprotocol/utils'; -import { t } from '@vegaprotocol/i18n'; import { ActionsDropdown, ButtonLink, @@ -30,6 +29,7 @@ import { import * as Schema from '@vegaprotocol/types'; import { type TimestampedWithdrawals } from './use-ready-to-complete-withdrawals-toast'; import classNames from 'classnames'; +import { useT } from './use-t'; export const WithdrawalsTable = ({ delayed, @@ -39,13 +39,14 @@ export const WithdrawalsTable = ({ ready?: TimestampedWithdrawals; delayed?: TimestampedWithdrawals; }) => { + const t = useT(); const createWithdrawApproval = useEthWithdrawApprovalsStore( (store) => store.create ); const columnDefs = useMemo( () => [ - { headerName: 'Asset', field: 'asset.symbol' }, + { headerName: t('Asset'), field: 'asset.symbol' }, { headerName: t('Amount'), field: 'amount', @@ -128,7 +129,7 @@ export const WithdrawalsTable = ({ }), }, ], - [createWithdrawApproval, delayed, ready] + [createWithdrawApproval, delayed, ready, t] ); return ( void; }; export const CompleteCell = ({ data, complete }: CompleteCellProps) => { + const t = useT(); const open = useWithdrawalApprovalDialog((state) => state.open); const ref = useRef(null); @@ -206,8 +208,8 @@ export const StatusCell = ({ ready?: TimestampedWithdrawals; delayed?: TimestampedWithdrawals; }) => { + const t = useT(); const READY_TO_COMPLETE = t('Ready to complete'); - const DELAYED = (readyIn: string) => t('Delayed (ready in %s)', readyIn); const PENDING = t('Pending'); const COMPLETED = t('Completed'); const REJECTED = t('Rejected'); @@ -246,7 +248,11 @@ export const StatusCell = ({ if (isDelayed.timestamp == null) return; const remaining = Date.now() - isDelayed.timestamp; if (remaining < 0) { - setLabel(DELAYED(convertToCountdownString(remaining, '0:00:00:00'))); + setLabel( + t('Delayed (ready in {{readyIn}})', { + readyIn: convertToCountdownString(remaining, '0:00:00:00'), + }) + ); } else { setLabel(READY_TO_COMPLETE); } @@ -254,7 +260,7 @@ export const StatusCell = ({ return () => { clearInterval(interval); }; - }, [READY_TO_COMPLETE, data, delayed, isDelayed, isPending]); + }, [READY_TO_COMPLETE, data, delayed, isDelayed, isPending, t]); return data ? (