From de14b90bcb4b08449358c016fb7fbaa25abbb52d Mon Sep 17 00:00:00 2001 From: Viktoryia Date: Mon, 4 Nov 2024 12:45:19 +0100 Subject: [PATCH] feat(staking): use tolgee keys (#976) * feat: setup namespaces Signed-off-by: viktoriabakun * feat: leave single translation file by lang with namespaces as keys in it Signed-off-by: viktoriabakun * feat(utils): use tolgee keys Signed-off-by: viktoriabakun * feat(utils): remove empty vals from json files Signed-off-by: viktoriabakun * chore: get rid of `any` in localisation components * feat(authz): use tolgee keys (#974) * feat(tolgee-keys): revoke-button Signed-off-by: viktoriabakun * feat(tolgee-keys): granter-table Signed-off-by: viktoriabakun * feat(tolgee-keys): grantee-table and some corrections Signed-off-by: viktoriabakun * feat(tolgee-keys): grantee-card Signed-off-by: viktoriabakun * feat(tolgee-keys): authz-grants-actions Signed-off-by: viktoriabakun * feat(tolgee-keys): authz-page Signed-off-by: viktoriabakun * feat(tolgee-keys): select options Signed-off-by: viktoriabakun --------- Signed-off-by: viktoriabakun * feat(tolgee-keys): stacking/stride, stacking validator page Signed-off-by: viktoriabakun * feat(tolgee-keys): finish stacking Signed-off-by: viktoriabakun * fix(tolgee-keys): plurals Signed-off-by: viktoriabakun --------- Signed-off-by: viktoriabakun Co-authored-by: Oleg Shilov --- apps/shell/src/i18n/en.json | 5 +- apps/shell/src/tolgee/shared.ts | 2 + .../lib/components/delegate-modal-hooked.tsx | 11 ++- .../src/lib/components/delegate-modal.tsx | 40 +++++++--- .../components/redelegate-modal-hooked.tsx | 13 +++- .../src/lib/components/redelegate-modal.tsx | 16 ++-- .../src/lib/components/staking-info.tsx | 15 +++- .../src/lib/components/staking-stats.tsx | 27 ++++--- .../liquid-staking-delegate-modal-hooked.tsx | 17 +++- .../stride/liquid-staking-delegate-modal.tsx | 45 ++++++++--- ...liquid-staking-undelegate-modal-hooked.tsx | 21 ++++- .../liquid-staking-undelegate-modal.tsx | 28 +++++-- .../stride/statistics/stride-stats.tsx | 31 +++++--- .../components/undelegate-modal-hooked.tsx | 13 +++- .../src/lib/components/undelegate-modal.tsx | 32 +++++--- .../lib/components/validator-block-mobile.tsx | 28 ++++--- .../src/lib/components/validator-info.tsx | 78 ++++++++++++------- .../lib/components/validator-list-desktop.tsx | 16 ++-- .../components/validator-list-item-mobile.tsx | 24 ++++-- .../lib/components/validator-list-mobile.tsx | 4 +- .../src/lib/components/validator-list.tsx | 27 ++++--- .../src/lib/components/validator-select.tsx | 4 +- .../src/lib/validator-details-page.tsx | 6 +- libs/staking/src/lib/validator-list-page.tsx | 4 +- package.json | 1 + pnpm-lock.yaml | 8 ++ 26 files changed, 356 insertions(+), 160 deletions(-) diff --git a/apps/shell/src/i18n/en.json b/apps/shell/src/i18n/en.json index cc7f26936..3d4ae4773 100644 --- a/apps/shell/src/i18n/en.json +++ b/apps/shell/src/i18n/en.json @@ -44,7 +44,10 @@ }, "governance": {}, "main": {}, - "stacking": {}, + "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}}", + "funds-undelegated-in-days": "The funds will be undelegated within {count, plural, one {# day} other {# days}}" + }, "uc-dao": {}, "utils": { "invalid-address": "Please enter a valid address", diff --git a/apps/shell/src/tolgee/shared.ts b/apps/shell/src/tolgee/shared.ts index af64acc1e..fbaf89ba0 100644 --- a/apps/shell/src/tolgee/shared.ts +++ b/apps/shell/src/tolgee/shared.ts @@ -1,3 +1,4 @@ +import { FormatIcu } from '@tolgee/format-icu'; import { DevTools, Tolgee, FormatSimple, TolgeeStaticData } from '@tolgee/web'; export type Locale = 'en' | 'ar' | 'id' | 'tr'; @@ -53,6 +54,7 @@ export function TolgeeBase() { Tolgee() .use(FormatSimple()) .use(DevTools()) + .use(FormatIcu()) // Preset shared settings .updateDefaults({ apiKey, diff --git a/libs/staking/src/lib/components/delegate-modal-hooked.tsx b/libs/staking/src/lib/components/delegate-modal-hooked.tsx index d3e002df6..797b1cd95 100644 --- a/libs/staking/src/lib/components/delegate-modal-hooked.tsx +++ b/libs/staking/src/lib/components/delegate-modal-hooked.tsx @@ -1,5 +1,6 @@ 'use client'; import { useCallback, useEffect, useRef, useState } from 'react'; +import { useTranslate } from '@tolgee/react'; import Link from 'next/link'; import { usePostHog } from 'posthog-js/react'; import { useDebounceValue } from 'usehooks-ts'; @@ -45,6 +46,7 @@ export function DelegateModalHooked({ unboundingTime, validatorCommission, }: DelegateModalProps) { + const { t } = useTranslate('staking'); const { delegate, getDelegateEstimatedFee } = useStakingActions(); const [delegateAmount, setDelegateAmount] = useState( undefined, @@ -96,7 +98,11 @@ export function DelegateModalHooked({ await toast.promise( delegationPromise, { - loading: Delegation in progress, + loading: ( + + {t('delegation-progress', 'Delegation in progress')} + + ), success: (tx) => { console.log('Delegation successful', { tx }); const txHash = tx?.txhash; @@ -115,7 +121,7 @@ export function DelegateModalHooked({ return (
-
Delegation successful
+
{t('delegation-success', 'Delegation successful')}
{ @@ -163,13 +165,21 @@ export function DelegateModal({ 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]); return ( @@ -183,25 +193,31 @@ export function DelegateModal({
- Delegate + {t('delegate', 'Delegate')} - {`Attention! If in the future you want to withdraw the staked funds, it will take ${unboundingTime} ${unboundingTime === 1 ? 'day' : 'days'}`} + {t( + '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}}', + { + count: unboundingTime, + }, + )}
@@ -227,7 +243,7 @@ export function DelegateModal({ setMemoVisible(true); }} > - Add memo + {t('add-memo', 'Add memo')}
) : ( @@ -245,14 +261,14 @@ export function DelegateModal({ 'px-[16px] py-[12px] text-[14px] font-[500] leading-[22px]', 'bg-[#E7E7E7]', )} - placeholder="Add your memo" + placeholder={t('memo-placeholder', 'Add your memo')} />
)}
@@ -265,7 +281,7 @@ export function DelegateModal({ className="w-full" disabled={isDisabled} > - Confirm delegation + {t('confirm-delegation', 'Confirm delegation')}
diff --git a/libs/staking/src/lib/components/redelegate-modal-hooked.tsx b/libs/staking/src/lib/components/redelegate-modal-hooked.tsx index 0ae4129eb..69eaaa7e7 100644 --- a/libs/staking/src/lib/components/redelegate-modal-hooked.tsx +++ b/libs/staking/src/lib/components/redelegate-modal-hooked.tsx @@ -1,6 +1,7 @@ 'use client'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { Validator } from '@evmos/provider'; +import { useTranslate } from '@tolgee/react'; import Link from 'next/link'; import { usePostHog } from 'posthog-js/react'; import { useDebounceValue } from 'usehooks-ts'; @@ -48,6 +49,7 @@ export function RedelegateModalHooked({ validatorsList, balance, }: RedelegateModalProps) { + const { t } = useTranslate('stacking'); const { haqqAddress, ethAddress } = useAddress(); const { data: redelegationValidatorAmount } = useRedelegationValidatorAmount( @@ -107,7 +109,11 @@ export function RedelegateModalHooked({ await toast.promise( redelegationPromise, { - loading: Redelegate in progress, + loading: ( + + {t('redelegate-progress', 'Redelegate in progress')} + + ), success: (tx) => { console.log('Redelegation successful', { tx }); const txHash = tx?.txhash; @@ -126,7 +132,9 @@ export function RedelegateModalHooked({ return (
-
Redelegation successful
+
+ {t('redelegate-success', 'Redelegation successful')} +
{ @@ -133,14 +135,14 @@ export function RedelegateModal({
- Redelegate + {t('redelegate', 'Redelegate')}
@@ -150,7 +152,7 @@ export function RedelegateModal({
@@ -183,7 +185,7 @@ export function RedelegateModal({ setMemoVisible(true); }} > - Add memo + {t('add-memo', 'Add memo')}
) : ( @@ -201,14 +203,14 @@ export function RedelegateModal({ 'px-[16px] py-[12px] text-[14px] font-[500] leading-[22px]', 'bg-[#E7E7E7]', )} - placeholder="Add your memo" + placeholder={t('memo-placeholder', 'Add your memo')} />
)}
@@ -221,7 +223,7 @@ export function RedelegateModal({ className="w-full" disabled={isDisabled} > - Confirm redelegation + {t('confirm-redelegation', 'Confirm redelegation')}
diff --git a/libs/staking/src/lib/components/staking-info.tsx b/libs/staking/src/lib/components/staking-info.tsx index 4148fb038..8539e6e54 100644 --- a/libs/staking/src/lib/components/staking-info.tsx +++ b/libs/staking/src/lib/components/staking-info.tsx @@ -1,5 +1,6 @@ 'use client'; import { useCallback, useEffect, useMemo, useState } from 'react'; +import { useTranslate } from '@tolgee/react'; import clsx from 'clsx'; import Link from 'next/link'; import { usePostHog } from 'posthog-js/react'; @@ -37,6 +38,7 @@ import { StakingStatsDesktop, StakingStatsMobile } from './staking-stats'; import { shouldUsePrecompile } from '../constants'; function useStakingStats() { + const { t } = useTranslate('staking'); const [delegatedValsAddrs, setDelegatedValsAddrs] = useState>( [], ); @@ -95,7 +97,11 @@ function useStakingStats() { }); await toast.promise(claimAllRewardPromise, { - loading: Rewards claim in progress, + loading: ( + + {t('rewards-progress', 'Rewards claim in progress')} + + ), success: (tx) => { console.log('Rewards claimed', { tx }); const txHash = tx?.txhash; @@ -103,7 +109,7 @@ function useStakingStats() { return (
-
Rewards claimed
+
{t('rewards-claimed', 'Rewards claimed')}
- You should connect wallet first + {t('connect-wallet-message', 'You should connect wallet first')}
diff --git a/libs/staking/src/lib/components/staking-stats.tsx b/libs/staking/src/lib/components/staking-stats.tsx index fa49c28de..5872fe576 100644 --- a/libs/staking/src/lib/components/staking-stats.tsx +++ b/libs/staking/src/lib/components/staking-stats.tsx @@ -1,3 +1,4 @@ +import { useTranslate } from '@tolgee/react'; import clsx from 'clsx'; import { Button, Tooltip } from '@haqq/shell-ui-kit'; import { @@ -58,12 +59,13 @@ export function StakingStatsDesktop({ onRewardsClaim, isRewardsPending = false, }: StakingStatsProps) { + const { t } = useTranslate('staking'); return (
- Regular staking + {t('regular-staking', 'Regular staking')}
@@ -72,7 +74,7 @@ export function StakingStatsDesktop({
@@ -80,7 +82,7 @@ export function StakingStatsDesktop({
@@ -88,7 +90,7 @@ export function StakingStatsDesktop({
@@ -96,7 +98,7 @@ export function StakingStatsDesktop({
@@ -118,7 +120,7 @@ export function StakingStatsDesktop({ variant={2} isLoading={isRewardsPending} > - Claim all rewards + {t('claim-all-rewards', 'Claim all rewards')}
@@ -173,6 +175,7 @@ export function StakingStatsMobile({ unbounded, isRewardsPending = false, }: StakingStatsProps) { + const { t } = useTranslate('staking'); return (
@@ -184,22 +187,22 @@ export function StakingStatsMobile({
- Get rewards + {t('get-rewards', 'Get rewards')}
diff --git a/libs/staking/src/lib/components/stride/liquid-staking-delegate-modal-hooked.tsx b/libs/staking/src/lib/components/stride/liquid-staking-delegate-modal-hooked.tsx index ce23d9edd..385dc8fec 100644 --- a/libs/staking/src/lib/components/stride/liquid-staking-delegate-modal-hooked.tsx +++ b/libs/staking/src/lib/components/stride/liquid-staking-delegate-modal-hooked.tsx @@ -1,5 +1,6 @@ 'use client'; import { useCallback, useEffect, useRef, useState } from 'react'; +import { useTranslate } from '@tolgee/react'; import Link from 'next/link'; import { usePostHog } from 'posthog-js/react'; import { useDebounceValue } from 'usehooks-ts'; @@ -37,6 +38,7 @@ export function LiquidStakingDelegateModalHooked({ balance, unboundingTime, }: LiquidStakingDelegateModalProps) { + const { t } = useTranslate('staking'); const [delegateAmount, setDelegateAmount] = useState( undefined, ); @@ -83,13 +85,21 @@ export function LiquidStakingDelegateModalHooked({ await toast.promise( delegationPromise, { - loading: Delegation in progress, + loading: ( + + {t('delegation-progress', 'Delegation in progress')} + + ), success: (tx) => { console.log('Delegation successful', { tx }); const txHash = tx?.txhash; if (!txHash) { - return Delegation declined; + return ( + + {t('delegation-declined', 'Delegation declined')} + + ); } posthog.capture('delegate success', { @@ -106,7 +116,7 @@ export function LiquidStakingDelegateModalHooked({ return (
-
Delegation successful
+
{t('delegation-success', 'Delegation successful')}
{ onChange(Math.floor(balance)); }, [balance, onChange]); @@ -158,13 +160,21 @@ export function LiquidStakingDelegateModal({ 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 { stIslmFormIslm } = useStIslmFormIslm(delegateAmount || 0); @@ -186,26 +196,32 @@ export function LiquidStakingDelegateModal({
- Delegate + {t('delegate-title', 'Delegate')} - {`Attention! If in the future you want to withdraw the staked funds, it will take ${unboundingTime} ${unboundingTime === 1 ? 'day' : 'days'}`} + {t( + '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}}', + { + count: unboundingTime, + }, + )}
@@ -227,7 +243,10 @@ export function LiquidStakingDelegateModal({ placeholder="Use your Stride address here" hint={ - Stride address is required to delegate + {t( + 'stride-address-required', + 'Stride address is required to delegate', + )} } /> @@ -235,9 +254,10 @@ export function LiquidStakingDelegateModal({
- What you'll get: + {t('you-will-get', "What you'll get:")}
+ {/* eslint-disable-next-line i18next/no-literal-string */} {formatNumber(stIslmFormIslm)} stISLM
@@ -245,9 +265,10 @@ export function LiquidStakingDelegateModal({ {annualizedYield ? (
- Annual percentage yield + {t('annualized-yield', 'Annual percentage yield')}
+ {/* eslint-disable-next-line i18next/no-literal-string */} {formatNumber(annualizedYield)} stISLM
@@ -261,7 +282,7 @@ export function LiquidStakingDelegateModal({ className="w-full" disabled={isDisabled} > - Confirm delegation + {t('confirm-delegation', 'Confirm delegation')}
diff --git a/libs/staking/src/lib/components/stride/liquid-staking-undelegate-modal-hooked.tsx b/libs/staking/src/lib/components/stride/liquid-staking-undelegate-modal-hooked.tsx index 987b5d63e..61bfefc18 100644 --- a/libs/staking/src/lib/components/stride/liquid-staking-undelegate-modal-hooked.tsx +++ b/libs/staking/src/lib/components/stride/liquid-staking-undelegate-modal-hooked.tsx @@ -1,5 +1,6 @@ 'use client'; import { useCallback, useEffect, useRef, useState } from 'react'; +import { useTranslate } from '@tolgee/react'; import Link from 'next/link'; import { usePostHog } from 'posthog-js/react'; import { useDebounceValue } from 'usehooks-ts'; @@ -39,6 +40,7 @@ export function LiquidStakingUndelegateModalHooked({ delegation, unboundingTime, }: LiquidStakingUndelegateModalProps) { + const { t } = useTranslate('stacking'); const { undelegate, setStrideAddress, strideAddress } = useLiquidStakingUndelegate(); const [undelegateAmount, setUndelegateAmount] = useState( @@ -80,13 +82,21 @@ export function LiquidStakingUndelegateModalHooked({ await toast.promise( undelegationPromise, { - loading: Undlegation in progress, + loading: ( + + {t('undelegation-progress', 'Undelegation in progress')} + + ), success: (tx) => { - console.log('Undlegation successful', { tx }); + console.log('Undelegation successful', { tx }); const txHash = tx?.txhash; if (!txHash) { - return Undelegation declined; + return ( + + {t('undelegation-declined', 'Undelegation declined')} + + ); } posthog.capture('undelegate success', { @@ -103,7 +113,9 @@ export function LiquidStakingUndelegateModalHooked({ return (
-
Undelegation successful
+
+ {t('undelegation-success', 'Undelegation successful')} +
{ onChange(delegation); }, [delegation, onChange]); @@ -72,15 +74,23 @@ export function LiquidStakingUndelegateModal({ const amountHint = useMemo(() => { if (amountError === 'min') { - return Bellow minimal value; + return ( + + {t('amount-error-min', 'Bellow minimal value', { ns: 'stacking' })} + + ); } else if (amountError === 'max') { return ( - More than your delegation + + {t('amount-error-more-than-delegation', 'More than your delegation', { + ns: 'stacking', + })} + ); } return undefined; - }, [amountError]); + }, [amountError, t]); return ( @@ -94,7 +104,7 @@ export function LiquidStakingUndelegateModal({
- Undelegate + {t('undelegate', 'Undelegate', { ns: 'common' })} - Stride address is required to undelegate + {t( + 'stride-address-required', + 'Stride address is required to undelegate', + { ns: 'stacking' }, + )} } /> @@ -145,7 +159,9 @@ export function LiquidStakingUndelegateModal({ className="w-full" disabled={isDisabled} > - Confirm undelegation + {t('confirm-undelegation', 'Confirm undelegation', { + ns: 'stacking', + })}
diff --git a/libs/staking/src/lib/components/stride/statistics/stride-stats.tsx b/libs/staking/src/lib/components/stride/statistics/stride-stats.tsx index 2ee16d41a..f5ff7ca83 100644 --- a/libs/staking/src/lib/components/stride/statistics/stride-stats.tsx +++ b/libs/staking/src/lib/components/stride/statistics/stride-stats.tsx @@ -1,4 +1,5 @@ import { useCallback, useMemo } from 'react'; +import { useTranslate } from '@tolgee/react'; import clsx from 'clsx'; import { useRouter } from 'next/navigation'; import { useMediaQuery } from 'usehooks-ts'; @@ -118,6 +119,7 @@ function StrideStatsDesktop({ stIslmBalance: number; islmAmountFromStIslm: number; }) { + const { t } = useTranslate(); const { handleDelegateContinue, handleUndelegateContinue } = useHandleDelegateContinue(); @@ -126,7 +128,7 @@ function StrideStatsDesktop({
- Liquid staking + {t('liquid-staking', 'Liquid staking', { ns: 'stacking' })}
@@ -135,7 +137,7 @@ function StrideStatsDesktop({
- Delegate + {t('delegate', 'Delegate', { ns: 'common' })}
@@ -184,7 +188,7 @@ function StrideStatsDesktop({ handleUndelegateContinue(); }} > - Undelegate + {t('undelegate', 'Undelegate', { ns: 'common' })}
@@ -203,6 +207,7 @@ function StrideStatsMobile({ stIslmBalance: number; islmAmountFromStIslm: number; }) { + const { t } = useTranslate(); const { handleDelegateContinue, handleUndelegateContinue } = useHandleDelegateContinue(); @@ -211,25 +216,27 @@ function StrideStatsMobile({
- Liquid staking + {t('liquid-staking', 'Liquid staking', { ns: 'stacking' })}
- Delegate + {t('delegate', 'Delegate', { ns: 'common' })}
diff --git a/libs/staking/src/lib/components/undelegate-modal-hooked.tsx b/libs/staking/src/lib/components/undelegate-modal-hooked.tsx index 1a212d6e5..283c6617e 100644 --- a/libs/staking/src/lib/components/undelegate-modal-hooked.tsx +++ b/libs/staking/src/lib/components/undelegate-modal-hooked.tsx @@ -1,5 +1,6 @@ 'use client'; import { useCallback, useEffect, useRef, useState } from 'react'; +import { useTranslate } from '@tolgee/react'; import Link from 'next/link'; import { usePostHog } from 'posthog-js/react'; import { useDebounceValue } from 'usehooks-ts'; @@ -43,6 +44,7 @@ export function UndelegateModalHooked({ unboundingTime, validatorAddress, }: UndelegateModalProps) { + const { t } = useTranslate('staking'); const { undelegate, getUndelegateEstimatedFee } = useStakingActions(); const [undelegateAmount, setUndelegateAmount] = useState( undefined, @@ -94,7 +96,11 @@ export function UndelegateModalHooked({ await toast.promise( undelegationPromise, { - loading: Undlegation in progress, + loading: ( + + {t('undelegation-progress', 'Undelegation in progress')} + + ), success: (tx) => { console.log('Undlegation successful', { tx }); const txHash = tx?.txhash; @@ -112,7 +118,9 @@ export function UndelegateModalHooked({ return (
-
Undelegation successful
+
+ {t('undelegation-success', 'Undelegation successful')} +
{ @@ -79,15 +81,21 @@ export function UndelegateModal({ 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 your delegation + + {t('amount-error-more-than-delegation', 'More than your delegation')} + ); } return undefined; - }, [amountError]); + }, [amountError, t]); return ( @@ -101,7 +109,7 @@ export function UndelegateModal({
- Undelegate + {t('undelegate', 'Undelegate')} - {`The funds will be undelegate within ${unboundingTime} day`} + {t('funds-undelegated-in-days', { + count: unboundingTime, + })}
@@ -144,7 +154,7 @@ export function UndelegateModal({ setMemoVisible(true); }} > - Add memo + {t('add-memo', 'Add memo')}
) : ( @@ -162,14 +172,14 @@ export function UndelegateModal({ 'px-[16px] py-[12px] text-[14px] font-[500] leading-[22px]', 'bg-[#E7E7E7]', )} - placeholder="Add your memo" + placeholder={t('memo-placeholder', 'Add your memo')} />
)}
@@ -182,7 +192,7 @@ export function UndelegateModal({ className="w-full" disabled={isDisabled} > - Confirm undelegation + {t('confirm-undelegation', 'Confirm undelegation')}
diff --git a/libs/staking/src/lib/components/validator-block-mobile.tsx b/libs/staking/src/lib/components/validator-block-mobile.tsx index 002dd926a..e8cc38837 100644 --- a/libs/staking/src/lib/components/validator-block-mobile.tsx +++ b/libs/staking/src/lib/components/validator-block-mobile.tsx @@ -1,4 +1,5 @@ import { PropsWithChildren } from 'react'; +import { useTranslate } from '@tolgee/react'; import clsx from 'clsx'; import { Button, Tooltip } from '@haqq/shell-ui-kit'; import { @@ -77,42 +78,49 @@ export function ValidatorBlockMobileComponent({ isRewardPending = false, minRewardsToClaim = 1, }: ValidatorBlockMobileProps) { + const { t } = useTranslate('staking'); return (
- Validator + {t('validator', 'Validator')}
{isWarningShown && (
- While the validator is inactive, you will not be able to receive a - reward. + {t( + 'validator-inactive-warning', + 'While the validator is inactive, you will not be able to receive a reward.', + )}
)}
- My delegation + + {t('my-delegation', 'My delegation')} + {formatNumber(delegation)} {symbol.toLocaleUpperCase()}
{undelegate && undelegate > 0 && (
- Undelegate in process + + {t('undelegate-process', 'Undelegate in process')} + {formatNumber(undelegate)} {symbol.toLocaleUpperCase()}
)}
- My rewards + {t('my-rewards', 'My rewards')} {formatNumber(rewards)} {symbol.toLocaleUpperCase()} @@ -129,7 +137,7 @@ export function ValidatorBlockMobileComponent({ disabled={isDelegateDisabled} data-attr="delegate" > - Delegate + {t('delegate', 'Delegate')}
@@ -140,7 +148,7 @@ export function ValidatorBlockMobileComponent({ disabled={isUndelegateDisabled} data-attr="undelegate" > - Undelegate + {t('undelegate', 'Undelegate')}
@@ -152,7 +160,7 @@ export function ValidatorBlockMobileComponent({ disabled={isRedelegateDisabled} data-attr="redelegate" > - Redelegate + {t('redelegate', 'Redelegate')}
@@ -171,7 +179,7 @@ export function ValidatorBlockMobileComponent({ isLoading={isRewardPending} data-attr="get-my-rewards" > - Get my rewards + {t('get-my-rewards', 'Get my rewards')}
diff --git a/libs/staking/src/lib/components/validator-info.tsx b/libs/staking/src/lib/components/validator-info.tsx index 05048bf36..f4aa5b730 100644 --- a/libs/staking/src/lib/components/validator-info.tsx +++ b/libs/staking/src/lib/components/validator-info.tsx @@ -1,6 +1,7 @@ 'use client'; import { Fragment, useCallback, useEffect, useMemo, useState } from 'react'; import type { Validator } from '@evmos/provider'; +import { useTranslate } from '@tolgee/react'; import clsx from 'clsx'; import Markdown from 'marked-react'; import dynamic from 'next/dynamic'; @@ -137,28 +138,29 @@ function CommissionCardInnerBlock({ } function CommissionCard({ commission }: CommissionCardProps) { + const { t } = useTranslate('stacking'); return (
- Commission + {t('comission', 'Commission')}
@@ -182,6 +184,7 @@ export function ValidatorInfoComponent({ isRewardPending, isRewardsPending, }: ValidatorInfoComponentProps) { + const { t } = useTranslate('stacking'); const [isHaqqAddressCopy, setHaqqAddressCopy] = useState(false); const { copyText } = useClipboard(); const isDesktop = useMediaQuery('(min-width: 1024px)', { @@ -250,7 +253,7 @@ export function ValidatorInfoComponent({
- Info + {t('info', 'Info')}
@@ -264,7 +267,7 @@ export function ValidatorInfoComponent({ target="_blank" rel="noreferrer noreferrer" > - Website + {t('website', 'Website')} )} @@ -272,7 +275,7 @@ export function ValidatorInfoComponent({ - E-mail + {t('email', 'E-mail')} )}
@@ -280,12 +283,14 @@ export function ValidatorInfoComponent({
- + {formatNumber(votingPower)} {symbol.toLocaleUpperCase()}
- + {votingPowerInPercents}
@@ -293,7 +298,7 @@ export function ValidatorInfoComponent({ {validatorInfo.description?.details && (
- Description + {t('description', 'Description')}
)} - + void; }) { + const { t } = useTranslate('common'); return (
- You should connect wallet first + {t('connect-wallet-message', 'You should connect wallet first')}
@@ -447,6 +453,7 @@ export function ValidatorInfo({ }: { validatorAddress: string; }) { + const { t } = useTranslate('stacking'); const { haqqAddress } = useAddress(); const chains = useChains(); const { chain = chains[0] } = useAccount(); @@ -550,7 +557,11 @@ export function ValidatorInfo({ }); await toast.promise(claimRewardPromise, { - loading: Rewards claim in progress, + loading: ( + + {t('rewards-claim-in-progress', 'Rewards claim in progress')} + + ), success: (tx) => { console.log('Rewards claimed', { tx }); const txHash = tx?.txhash; @@ -558,7 +569,7 @@ export function ValidatorInfo({ return (
-
Rewards claimed
+
{t('rewards-claimed', 'Rewards claimed')}
Rewards claim in progress, + loading: ( + + {t('rewards-claim-in-progress', 'Rewards claim in progress')} + + ), success: (tx) => { console.log('All rewards claimed', { tx }); const txHash = tx?.txhash; return (
-
Rewards claimed
+
{t('rewards-claimed', 'Rewards claimed')}
- Explorer link + {t('explorer-link', 'Explorer link')}
); @@ -716,6 +732,7 @@ export function ValidatorInfo({ getTotalRewards, invalidateQueries, posthog, + t, toast, ]); @@ -724,7 +741,7 @@ export function ValidatorInfo({
- Fetching validator information + {t('validator-info-loading', 'Fetching validator information')}
); @@ -772,6 +789,7 @@ export function ValidatorBlockDesktop({ symbol: string; isRewardPending?: boolean; }) { + const { t } = useTranslate('stacking'); const router = useRouter(); const isWarningShown = validatorInfo.jailed || validatorInfo.status === 'BOND_STATUS_UNBONDED'; @@ -797,15 +815,17 @@ export function ValidatorBlockDesktop({
- Validator + {t('validator', 'Validator')}
{isWarningShown && (
- While the validator is inactive, you will not be able to receive a - reward. + {t( + 'validator-inactive-warning', + 'While the validator is inactive, you will not be able to receive a reward.', + )}
)} @@ -813,7 +833,7 @@ export function ValidatorBlockDesktop({
- My delegation + {t('my-delegation', 'My delegation')} {formatNumber(delegation)} {symbol.toLocaleUpperCase()} @@ -834,7 +854,7 @@ export function ValidatorBlockDesktop({ }} data-attr="delegate" > - Delegate + {t('delegate', 'Delegate')}
@@ -852,7 +872,7 @@ export function ValidatorBlockDesktop({ }} data-attr="undelegate" > - Undelegate + {t('undelegate', 'Undelegate')}
@@ -871,14 +891,14 @@ export function ValidatorBlockDesktop({ }} data-attr="redelegate" > - Redelegate + {t('redelegate', 'Redelegate')}
- My rewards + {t('my-rewards', 'My rewards')} {formatNumber(rewards)} {symbol.toLocaleUpperCase()} @@ -888,7 +908,7 @@ export function ValidatorBlockDesktop({ @@ -900,7 +920,7 @@ export function ValidatorBlockDesktop({ className="w-full" data-attr="get-my-rewards" > - Get my rewards + {t('get-my-rewards', 'Get my rewards')}
diff --git a/libs/staking/src/lib/components/validator-list-desktop.tsx b/libs/staking/src/lib/components/validator-list-desktop.tsx index ad21c0233..4a9f74816 100644 --- a/libs/staking/src/lib/components/validator-list-desktop.tsx +++ b/libs/staking/src/lib/components/validator-list-desktop.tsx @@ -4,6 +4,7 @@ import { GetDelegationsResponse, Validator, } from '@evmos/provider'; +import { useTranslate } from '@tolgee/react'; import clsx from 'clsx'; import { ValidatorListItemDesktop } from './validator-list-item-desktop'; import { SortDirection, SortState } from '../hooks/use-validator-sort'; @@ -37,6 +38,7 @@ export function ValidatorsListDesktop({ onDesktopSortClick: (key: string) => void; sortState: SortState; }) { + const { t } = useTranslate('staking'); const getValidatorRewards = useCallback( (address: string) => { const rewards = rewardsInfo?.rewards?.find((rewardsItem) => { @@ -82,7 +84,7 @@ export function ValidatorsListDesktop({ onDesktopSortClick('name'); }} > - Name + {t('name', 'Name')} {sortState.key !== 'random' && sortState.key === 'name' && ( )} @@ -90,7 +92,7 @@ export function ValidatorsListDesktop({
- Status + {t('status', 'Status')} {sortState.key !== 'random' && sortState.key === 'status' && ( )} @@ -108,7 +110,7 @@ export function ValidatorsListDesktop({ onDesktopSortClick('fee'); }} > - Fee + {t('fee', 'Fee')} {sortState.key !== 'random' && sortState.key === 'fee' && ( )} @@ -126,7 +128,7 @@ export function ValidatorsListDesktop({ onDesktopSortClick('votingPower'); }} > - Voting power + {t('voting-power', 'Voting power')} {sortState.key !== 'random' && sortState.key === 'votingPower' && ( @@ -145,7 +147,7 @@ export function ValidatorsListDesktop({ onDesktopSortClick('votingPowerPercent'); }} > - Voting power % + {t('voting-power', 'Voting power')} % {sortState.key !== 'random' && sortState.key === 'votingPowerPercent' && ( @@ -164,7 +166,7 @@ export function ValidatorsListDesktop({ onDesktopSortClick('staked'); }} > - My stake + {t('my-stake', 'My stake')} {sortState.key !== 'random' && sortState.key === 'staked' && ( )} @@ -182,7 +184,7 @@ export function ValidatorsListDesktop({ onDesktopSortClick('reward'); }} > - My rewards + {t('my-rewards', 'My rewards')} {sortState.key !== 'random' && sortState.key === 'reward' && ( )} diff --git a/libs/staking/src/lib/components/validator-list-item-mobile.tsx b/libs/staking/src/lib/components/validator-list-item-mobile.tsx index ccc9d92f6..c8ee2f99c 100644 --- a/libs/staking/src/lib/components/validator-list-item-mobile.tsx +++ b/libs/staking/src/lib/components/validator-list-item-mobile.tsx @@ -1,6 +1,7 @@ 'use client'; import { PropsWithChildren, useCallback, useMemo } from 'react'; import type { Validator, DelegationResponse, Reward } from '@evmos/provider'; +import { useTranslate } from '@tolgee/react'; import { formatUnits, parseUnits } from 'viem'; import { formatNumber, Card } from '@haqq/shell-ui-kit/server'; @@ -35,6 +36,7 @@ export function ValidatorListItemMobileComponent({ votingPower, votingPowerPercent, }: ValidatorListItemMobileProps) { + const { t } = useTranslate('staking'); return (
@@ -43,28 +45,34 @@ export function ValidatorListItemMobileComponent({ {status === 'jailed' && ( - Jailed + + {t('jailed-status', 'Jailed')} + )} {status === 'active' && ( - Active + + {t('active-status', 'Active')} + )} {status === 'inactive' && ( - Inactive + + {t('inactive-status', 'Inactive')} + )} - + {fee} - + {votingPower} - + {votingPowerPercent} - + {staked} - + {reward}
diff --git a/libs/staking/src/lib/components/validator-list-mobile.tsx b/libs/staking/src/lib/components/validator-list-mobile.tsx index e625477d5..538e203f5 100644 --- a/libs/staking/src/lib/components/validator-list-mobile.tsx +++ b/libs/staking/src/lib/components/validator-list-mobile.tsx @@ -4,6 +4,7 @@ import { GetDelegationsResponse, Validator, } from '@evmos/provider'; +import { useTranslate } from '@tolgee/react'; import { ValidatorListItemMobile } from './validator-list-item-mobile'; export function ValidatorsListMobile({ @@ -19,6 +20,7 @@ export function ValidatorsListMobile({ onValidatorClick: (validatorAddress: string) => void; totalStaked: number; }) { + const { t } = useTranslate('common'); const getValidatorRewards = useCallback( (address: string) => { const rewards = rewardsInfo?.rewards?.find((rewardsItem) => { @@ -47,7 +49,7 @@ export function ValidatorsListMobile({ return (
- Nothing found + {t('nothing-found', 'Nothing found')}
); diff --git a/libs/staking/src/lib/components/validator-list.tsx b/libs/staking/src/lib/components/validator-list.tsx index 270ee61a2..ec5b89c3f 100644 --- a/libs/staking/src/lib/components/validator-list.tsx +++ b/libs/staking/src/lib/components/validator-list.tsx @@ -1,5 +1,6 @@ 'use client'; import { useCallback, useMemo } from 'react'; +import { useTranslate } from '@tolgee/react'; import clsx from 'clsx'; import { useRouter } from 'next/navigation'; import { useMediaQuery } from 'usehooks-ts'; @@ -23,6 +24,7 @@ export function ValidatorList({ isMobileUserAgent: boolean; seedPhrase: string; }) { + const { t } = useTranslate('staking'); const { totalStaked, valsTotal, @@ -109,7 +111,7 @@ export function ValidatorList({
- Validators + {t('validators', 'Validators')} {status !== 'pending' && (  ({validatorsCounterText}) @@ -121,17 +123,17 @@ export function ValidatorList({
@@ -143,7 +145,7 @@ export function ValidatorList({ disabled={!isWalletConnected} value={isWalletConnected ? isShowMyDelegation : false} > - My delegations + {t('my-delegations', 'My delegations')}
@@ -151,7 +153,7 @@ export function ValidatorList({ onChange={setInactiveValidatorsVisible} value={isInactiveValidatorsVisible} > - Show Inactive + {t('show-inactive', 'Show inactive')}
@@ -163,12 +165,13 @@ export function ValidatorList({
- Fetching validators list + {t('fetching-validators-message', 'Fetching validators list')}
)} + {/* TODO: how to translate such errors if they come from BE?*/} {status === 'error' && (

Error: {error?.message ?? 'unknown error'}

)} diff --git a/libs/staking/src/lib/components/validator-select.tsx b/libs/staking/src/lib/components/validator-select.tsx index 8131924e6..d87c241f9 100644 --- a/libs/staking/src/lib/components/validator-select.tsx +++ b/libs/staking/src/lib/components/validator-select.tsx @@ -1,5 +1,6 @@ 'uce client'; import { useCallback, useMemo } from 'react'; +import { useTranslate } from '@tolgee/react'; import clsx from 'clsx'; import Select, { components as validatorSelectComponents, @@ -33,6 +34,7 @@ export function ValidatorSelect({ validators: Array; onChange: (validatorAddress?: string) => void; }) { + const { t } = useTranslate('stacking'); const handleFilterOption = useCallback( ({ label, value }: ValidatorSelectOption, inputValue: string) => { const inputLower = inputValue.toLowerCase(); @@ -94,7 +96,7 @@ export function ValidatorSelect({ return (