diff --git a/apps/shell/src/i18n/en.json b/apps/shell/src/i18n/en.json index 3d4ae4773..a912bb1e6 100644 --- a/apps/shell/src/i18n/en.json +++ b/apps/shell/src/i18n/en.json @@ -42,7 +42,9 @@ "undelegate": "Undelegate", "redelegate": "Redelegate" }, - "governance": {}, + "governance": { + "your-balance": "Your balance: {{localedBalance}} {{localedSymbolUpperCase}}" + }, "main": {}, "stacking": { "attention-withdrawal-warning": "Attention! If in the future you want to withdraw the staked funds, it will take {{count}} day{count, plural, one {} other {s}}", diff --git a/libs/governance/src/index.ts b/libs/governance/src/index.ts index 5873e7a12..dfc96009f 100644 --- a/libs/governance/src/index.ts +++ b/libs/governance/src/index.ts @@ -1,3 +1,4 @@ export * from './lib/proposal-list-page'; export * from './lib/proposal-details-page'; export * from './lib/components/proposal-list-card'; +export * from './lib/hooks/useGetProposalTypeText'; diff --git a/libs/governance/src/lib/components/parameter-change-proposal.tsx b/libs/governance/src/lib/components/parameter-change-proposal.tsx index cceb252a7..193872130 100644 --- a/libs/governance/src/lib/components/parameter-change-proposal.tsx +++ b/libs/governance/src/lib/components/parameter-change-proposal.tsx @@ -1,4 +1,5 @@ import { ParameterChangeProposalContent } from '@evmos/provider'; +import { useTranslate } from '@tolgee/react'; import { Heading } from '@haqq/shell-ui-kit/server'; import { Metadata } from './metadata'; @@ -7,6 +8,7 @@ export function ParameterChangeProposalDetails({ }: { content: ParameterChangeProposalContent; }) { + const { t } = useTranslate('governance'); return (
@@ -26,7 +28,7 @@ export function ParameterChangeProposalDetails({ - Parameter changes + {t('parameter-changes', 'Parameter changes')}
{JSON.stringify(content.changes, null, 2)} diff --git a/libs/governance/src/lib/components/proposal-deposit-modal.tsx b/libs/governance/src/lib/components/proposal-deposit-modal.tsx index c262a88f2..ad6de4164 100644 --- a/libs/governance/src/lib/components/proposal-deposit-modal.tsx +++ b/libs/governance/src/lib/components/proposal-deposit-modal.tsx @@ -1,5 +1,6 @@ 'use client'; import { useCallback, useEffect, useMemo, useState } from 'react'; +import { useTranslate } from '@tolgee/react'; import clsx from 'clsx'; import { Button, @@ -65,6 +66,7 @@ export function ProposalDepositModal({ onSubmit: (amount: number) => void; isPending?: boolean; }) { + const { t } = useTranslate('governance'); const [depositAmount, setDepositAmount] = useState( undefined, ); @@ -101,13 +103,21 @@ export function ProposalDepositModal({ const amountHint = useMemo(() => { if (amountError === 'min') { - return Bellow minimal value; + return ( + + {t('amount-error-min', 'Bellow minimal value')} + + ); } else if (amountError === 'max') { - return More than you have; + return ( + + {t('amount-error-more-than-have', 'More than you have')} + + ); } return undefined; - }, [amountError]); + }, [amountError, t]); const handleMaxButtonClick = useCallback(() => { setDepositAmount(balance); @@ -129,12 +139,12 @@ export function ProposalDepositModal({
- Deposit + {t('deposit', 'Deposit')}
@@ -157,7 +167,7 @@ export function ProposalDepositModal({ disabled={!isDepositEnabled || !depositAmount} isLoading={isPending} > - Confirm delegation + {t('confirm-delegation', 'Confirm delegation')}
diff --git a/libs/governance/src/lib/components/proposal-list-card.tsx b/libs/governance/src/lib/components/proposal-list-card.tsx index f40f369de..a391e1c3e 100644 --- a/libs/governance/src/lib/components/proposal-list-card.tsx +++ b/libs/governance/src/lib/components/proposal-list-card.tsx @@ -6,7 +6,7 @@ import { TallyResults, } from '@haqq/data-access-cosmos'; import { ProposalCard, ProposalStatusEnum } from '@haqq/shell-ui-kit/server'; -import { getProposalTypeText } from '../proposal-details-page'; +import { useGetProposalTypeText } from '../hooks/useGetProposalTypeText'; export function ProposalListCard({ proposal, @@ -54,7 +54,7 @@ export function ProposalListCard({ minDeposit={minDeposit} results={proposalTally} symbol={symbol} - type={getProposalTypeText(proposal.content['@type'])} + type={useGetProposalTypeText(proposal.content['@type'])} userVote={userVote} className={className} /> diff --git a/libs/governance/src/lib/components/software-upgrade-proposal.tsx b/libs/governance/src/lib/components/software-upgrade-proposal.tsx index 2ca1cb0ca..93579308f 100644 --- a/libs/governance/src/lib/components/software-upgrade-proposal.tsx +++ b/libs/governance/src/lib/components/software-upgrade-proposal.tsx @@ -1,4 +1,5 @@ import { useMemo } from 'react'; +import { useTranslate } from '@tolgee/react'; import { Heading } from '@haqq/shell-ui-kit/server'; import { Metadata } from './metadata'; @@ -15,6 +16,7 @@ export function SoftwareUpgradeProposalDetails({ }: { plan: SoftwareUpgradeProposalPlan; }) { + const { t } = useTranslate('governance'); const formattedPlan = useMemo(() => { return { name: plan.name, @@ -44,7 +46,7 @@ export function SoftwareUpgradeProposalDetails({ - Upgrade plan + {t('upgrade-plan', 'Upgrade plan')}
diff --git a/libs/governance/src/lib/hooks/useGetProposalTypeText.tsx b/libs/governance/src/lib/hooks/useGetProposalTypeText.tsx new file mode 100644 index 000000000..2306d0f0a --- /dev/null +++ b/libs/governance/src/lib/hooks/useGetProposalTypeText.tsx @@ -0,0 +1,44 @@ +import { useTranslate } from '@tolgee/react'; + +export const enum ProposalTypes { + Text = '/cosmos.gov.v1beta1.TextProposal', + SoftwareUpgrade = '/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal', + CancelSoftwareUpgrade = '/cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal', + ParameterChange = '/cosmos.params.v1beta1.ParameterChangeProposal', + ClientUpdate = '/ibc.core.client.v1.ClientUpdateProposal', + RegisterCoin = '/evmos.erc20.v1.RegisterCoinProposal', + RegisterERC20 = '/evmos.erc20.v1.RegisterERC20Proposal', +} + +export function useGetProposalTypeText(type: string) { + const { t } = useTranslate('governance'); + + switch (type) { + case ProposalTypes.Text: + return t('proposal-types.text', 'Text'); + + case ProposalTypes.SoftwareUpgrade: + return t('proposal-types.software-upgrade', 'Software upgrade'); + + case ProposalTypes.CancelSoftwareUpgrade: + return t( + 'proposal-types.cancel-software-upgrade', + 'Cancel software upgrade', + ); + + case ProposalTypes.ClientUpdate: + return t('proposal-types.client-update', 'Client update'); + + case ProposalTypes.ParameterChange: + return t('proposal-types.parameter-change', 'Parameter change'); + + case ProposalTypes.RegisterCoin: + return t('proposal-types.register-coin', 'Register coin'); + + case ProposalTypes.RegisterERC20: + return t('proposal-types.register-erc20', 'Register ERC20'); + + default: + return type; + } +} diff --git a/libs/governance/src/lib/proposal-details-page.tsx b/libs/governance/src/lib/proposal-details-page.tsx index 69fe7efc5..385b2ca2d 100644 --- a/libs/governance/src/lib/proposal-details-page.tsx +++ b/libs/governance/src/lib/proposal-details-page.tsx @@ -12,6 +12,7 @@ import { Proposal, SoftwareUpgradeProposalContent, } from '@evmos/provider'; +import { useTranslate } from '@tolgee/react'; import clsx from 'clsx'; import Markdown from 'marked-react'; import Link from 'next/link'; @@ -67,52 +68,19 @@ import { } from '@haqq/shell-ui-kit/server'; import { ParameterChangeProposalDetails } from './components/parameter-change-proposal'; import { SoftwareUpgradeProposalDetails } from './components/software-upgrade-proposal'; - -const enum ProposalTypes { - Text = '/cosmos.gov.v1beta1.TextProposal', - SoftwareUpgrade = '/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal', - CancelSoftwareUpgrade = '/cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal', - ParameterChange = '/cosmos.params.v1beta1.ParameterChangeProposal', - ClientUpdate = '/ibc.core.client.v1.ClientUpdateProposal', - RegisterCoin = '/evmos.erc20.v1.RegisterCoinProposal', - RegisterERC20 = '/evmos.erc20.v1.RegisterERC20Proposal', -} - -export function getProposalTypeText(type: string) { - switch (type) { - case ProposalTypes.Text: - return 'Text'; - - case ProposalTypes.SoftwareUpgrade: - return 'Software upgrade'; - - case ProposalTypes.CancelSoftwareUpgrade: - return 'Cancel software upgrade'; - - case ProposalTypes.ClientUpdate: - return 'Client update'; - - case ProposalTypes.ParameterChange: - return 'Parameter change'; - - case ProposalTypes.RegisterCoin: - return 'Register coin'; - - case ProposalTypes.RegisterERC20: - return 'Register ERC20'; - - default: - return type; - } -} +import { + ProposalTypes, + useGetProposalTypeText, +} from './hooks/useGetProposalTypeText'; function ShowDateToggleButton({ onClick }: { onClick: () => void }) { + const { t } = useTranslate('governance'); return (
- {getProposalTypeText(proposalDetails.content['@type'])} + {useGetProposalTypeText(proposalDetails.content['@type'])}
@@ -430,7 +401,7 @@ export function ProposalDetailsComponent({
- Info + {t('info', 'Info')}
@@ -443,7 +414,7 @@ export function ProposalDetailsComponent({
*/}
- + {formatNumber(totalDeposit)}{' '} {symbol.toLocaleUpperCase()} @@ -451,7 +422,7 @@ export function ProposalDetailsComponent({
- Description + {t('description', 'Description')}
- Dates + {t('dates', 'Dates')}
- + {formatDate(new Date(proposalDetails.submit_time))} - + {formatDate(new Date(proposalDetails.deposit_end_time))} {proposalDetails.status !== ProposalStatusEnum.Deposit && ( - + {formatDate( new Date(proposalDetails.voting_start_time), )} - + {formatDate( new Date(proposalDetails.voting_end_time), )} @@ -573,7 +544,7 @@ export function ProposalDetailsComponent({ - Created at (gmt) + {t('created-at', 'Created at (gmt)')} @@ -594,7 +565,7 @@ export function ProposalDetailsComponent({ - Deposit end (gmt) + {t('deposit-end', 'Deposit end (gmt)')} @@ -617,7 +588,7 @@ export function ProposalDetailsComponent({ - Vote start (gmt) + {t('vote-start', 'Vote start (gmt)')} @@ -640,7 +611,7 @@ export function ProposalDetailsComponent({ - Vote end (gmt) + {t('vote-end', 'Vote end (gmt)')} @@ -694,7 +665,7 @@ export function ProposalDetailsComponent({ )} {proposalDetails.status === ProposalStatusEnum.Voting && @@ -702,7 +673,7 @@ export function ProposalDetailsComponent({ )}
@@ -838,19 +809,20 @@ function ProposalActionsMobile({ isCanVote?: boolean; userVote?: string | null; }) { + const { t } = useTranslate('common'); if (!isConnected) { return (
- You should connect wallet first + {t('connect-wallet-message', 'You should connect wallet first')}
@@ -891,6 +863,7 @@ function ProposalActionsMobile({ } function ProposalInfo({ proposalId }: { proposalId: string }) { + const { t } = useTranslate('governance'); const { data: proposalDetails, isFetched } = useProposalDetailsQuery(proposalId); const { data: proposalTally } = useProposalTallyQuery(proposalId); @@ -907,7 +880,7 @@ function ProposalInfo({ proposalId }: { proposalId: string }) {
- Fetching proposal details + {t('fetching-proposal-details', 'Fetching proposal details')}
) : ( @@ -922,12 +895,13 @@ function ProposalInfo({ proposalId }: { proposalId: string }) { } export function ProposalDetailsPage({ proposalId }: { proposalId: string }) { + const { t } = useTranslate('common'); return (
- Governance + {t('governance', 'Governance')}
@@ -944,6 +918,7 @@ export function VoteActions({ proposalId: number; userVote?: string | null; }) { + const { t } = useTranslate('governance'); const { vote, getVoteEstimatedFee } = useProposalActions(); const toast = useToast(); const { executeIfNetworkSupported } = useNetworkAwareAction(); @@ -969,7 +944,11 @@ export function VoteActions({ ); await toast.promise(votePromise, { - loading: Vote in progress, + loading: ( + + {t('vote-in-progress', 'Vote in progress')} + + ), success: (tx) => { console.log('Vote successful', { tx }); const txHash = tx?.txhash; @@ -977,7 +956,9 @@ export function VoteActions({ return (
-
Your vote will be counted!!!
+
+ {t('vote-will-count', 'Your vote will be counted!!!')} +
{ console.error(error); - return For some reason your vote failed.; + return ( + + {t('vote-fail-error', 'For some reason your vote failed.')} + + ); }, }); posthog.capture('vote success', { chainId }); @@ -1012,6 +997,7 @@ export function VoteActions({ memo, posthog, proposalId, + t, toast, vote, ], @@ -1024,9 +1010,14 @@ export function VoteActions({ return (
- Cast your vote + + {t('cast-vote', 'Cast your vote')} +
- You can change your vote while the voting is in progress + {t( + 'change-vote-message', + 'You can change your vote while the voting is in progress', + )}
@@ -1038,7 +1029,7 @@ export function VoteActions({ setMemoVisible(true); }} > - Add memo + {t('add-memo', 'Add memo')}
) : ( @@ -1055,7 +1046,7 @@ export function VoteActions({ 'rounded-[6px] bg-[#252528]', 'disabled:cursor-not-allowed', )} - placeholder="Add your memo" + placeholder={t('add-your-memo', 'Add your memo')} autoFocus />
@@ -1075,7 +1066,7 @@ export function VoteActions({ voteOptionFromJSON(userVote) === VoteOption.VOTE_OPTION_YES } > - Yes + {t('vote-option-yes', 'Yes')}
@@ -1091,7 +1082,7 @@ export function VoteActions({ voteOptionFromJSON(userVote) === VoteOption.VOTE_OPTION_NO } > - No + {t('vote-option-no', 'No')}
@@ -1107,7 +1098,7 @@ export function VoteActions({ voteOptionFromJSON(userVote) === VoteOption.VOTE_OPTION_ABSTAIN } > - Abstain + {t('vote-option-abstain', 'Abstain')}
@@ -1124,7 +1115,7 @@ export function VoteActions({ VoteOption.VOTE_OPTION_NO_WITH_VETO } > - Veto + {t('vote-option-veto', 'Veto')}
@@ -1141,6 +1132,7 @@ export function DepositActionsDesktop({ onDepositSubmit: (depositAmount: number) => void; isConnected: boolean; }) { + const { t } = useTranslate('governance'); const [depositAmount, setDepositAmount] = useState( undefined, ); @@ -1152,14 +1144,21 @@ export function DepositActionsDesktop({ const symbol = 'ISLM'; const { executeIfNetworkSupported } = useNetworkAwareAction(); + const localedBalance = balance.toLocaleString(); + const localedSymbolUpperCase = symbol.toLocaleUpperCase(); + return (
- Enter the amount you want to deposit + {t('enter-deposit-message', 'Enter the amount you want to deposit')}
- You balance: {balance.toLocaleString()} {symbol.toLocaleUpperCase()} + {t( + 'your-balance', + 'Your balance: {localedBalance} {localedSymbolUpperCase}', + { localedBalance, localedSymbolUpperCase }, + )}
@@ -1179,7 +1178,7 @@ export function DepositActionsDesktop({ !isConnected || (depositAmount && depositAmount === 0), )} > - Deposit + {t('deposit', 'Deposit')}
@@ -1197,11 +1196,12 @@ export function DepositInput({ value: number | undefined; disabled?: boolean; }) { + const { t } = useTranslate('governance'); return (
- If the proposal does not collect the required number of deposits in a - certain time, it will reject + {t( + 'proposal-deposit-alert', + 'If the proposal does not collect the required number of deposits in a certain time, it will reject', + )} ); } diff --git a/libs/governance/src/lib/proposal-list-page.tsx b/libs/governance/src/lib/proposal-list-page.tsx index 5c96bb157..cb09e777d 100644 --- a/libs/governance/src/lib/proposal-list-page.tsx +++ b/libs/governance/src/lib/proposal-list-page.tsx @@ -1,6 +1,7 @@ 'use client'; import { useMemo } from 'react'; import { ProposalStatus } from '@evmos/provider'; +import { useTranslate } from '@tolgee/react'; import Link from 'next/link'; import { useAddress, @@ -14,6 +15,7 @@ import { Container, SpinnerLoader } from '@haqq/shell-ui-kit/server'; import { ProposalListCard } from './components/proposal-list-card'; export function ProposalListPage() { + const { t } = useTranslate(); const { data: govParams } = useGovernanceParamsQuery(); const { data: proposalsData } = useProposalListQuery(); const symbol = 'ISLM'; @@ -98,7 +100,7 @@ export function ProposalListPage() {
- Governance + {t('governance-title', 'Governance', { ns: 'common' })}
@@ -111,7 +113,9 @@ export function ProposalListPage() {
- Fetching proposals + {t('fetching-proposals', 'Fetching proposals', { + ns: 'governance', + })}