Skip to content

Commit

Permalink
feat: i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
cs1707 committed Sep 21, 2023
1 parent 6dbe6ed commit b55cad4
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 24 deletions.
10 changes: 10 additions & 0 deletions _raw/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,16 @@
"empty": "Not found in any node",
"reBroadcastBtn": "Re-broadcast",
"title": "Found in the below memopools"
},
"message": {
"broadcastSuccess": "Broadcasted",
"cancelSuccess": "Canceled"
},
"gas": {
"noCost": "No Gas cost"
},
"SkipNonceAlert": {
"alert": "Nonce #{{nonce}} skipped on {{chainName}} chain. This may cause pending transactions ahead. <1/> <2>Submit a tx</2> <3/> on chain to resolve"
}
},
"signedText": {
Expand Down
37 changes: 35 additions & 2 deletions _raw/locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -623,16 +623,49 @@
"canceled": "已取消",
"failed": "交易失败",
"pending": "待完成",
"submitFailed": "提交失败"
"submitFailed": "提交失败",
"pendingBroadcast": "Pending: 等待广播",
"pendingBroadcasted": "Pending: 已广播",
"withdrawed": "已快捷取消"
},
"tips": {
"canNotCancel": "无法加速或取消:不是第一个待完成的交易",
"pendingDetail": "只会有一笔交易成功完成,而且一般是 Gas Price 最高的一笔交易将成功"
"pendingDetail": "只会有一笔交易成功完成,而且一般是 Gas Price 最高的一笔交易将成功",
"pendingBroadcastRetry": "广播失败,上次广播时间:{{pushAt}}",
"pendingBroadcastRetryBtn": "重新广播",
"pendingBroadcast": "已设置为省Gas广播模式,正在等链上Gas较低的时广播。最晚将在创建后{{deadline}}后广播。",
"pendingBroadcastBtn": "立即广播"
},
"txType": {
"cancel": "取消交易",
"initial": "发起交易",
"speedUp": "加速交易"
},
"MempoolList": {
"empty": "未发现包含这笔交易的节点",
"reBroadcastBtn": "重新广播",
"title": "已在以下节点的memopool发现这笔交易"
},
"message": {
"broadcastSuccess": "已广播",
"cancelSuccess": "已取消"
},
"CancelTxPopup": {
"title": "取消交易",
"options": {
"quickCancel": {
"title": "快捷取消",
"desc": "不需要发起链上取消,不需要Gasfee",
"tips": "不是等待广播的交易,不支持快捷取消"
},
"onChainCancel": {
"title": "链上取消",
"desc": "发起新的链上交易来取消,需要Gasfee"
}
}
},
"SkipNonceAlert": {
"alert": "当前{{chainName}}链因快捷取消导致Nonce#{{nonce}}被跳过, 导致后续Pending交易无法完成, 可<1/><2>发起一笔链上交易</2><3/>来填充"
}
},
"title": "签名记录"
Expand Down
2 changes: 1 addition & 1 deletion src/ui/views/Approval/components/BroadcastMode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export const BroadcastMode = ({
}}
>
<div className="flex items-center gap-[4px]">
<div>
<div className="mr-auto">
<div className="option-title">{option.title}</div>
<div className="option-desc">{option.desc}</div>
</div>
Expand Down
27 changes: 18 additions & 9 deletions src/ui/views/TransactionHistory/components/SkipNonceAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ConnectedSite } from 'background/service/permission';
import { CHAINS, INTERNAL_REQUEST_ORIGIN } from 'consts';
import { flatten, maxBy } from 'lodash';
import React from 'react';
import { Trans } from 'react-i18next';
import styled from 'styled-components';
import IconWarning from 'ui/assets/signature-record/warning.svg';

Expand Down Expand Up @@ -57,17 +58,25 @@ const AlertDetail = ({
<div className="alert-detail">
<img src={IconWarning} alt="" />
<div className="alert-detail-content">
Nonce #{data.nonce} skipped on {chain?.name || 'Unkown'} chain. This may
cause pending transactions ahead.{' '}
<span
className="link"
onClick={() => {
onSubmitTx?.(data);
<Trans
i18nKey="page.activities.signedTx.SkipNonceAlert.alert"
values={{
nonce: data.nonce,
chainName: chain?.name || 'Unknown',
}}
>
Submit a tx
</span>{' '}
on chain to resolve
Nonce #{data.nonce} skipped on {chain?.name || 'Unknown'} chain. This
may cause pending transactions ahead.{' '}
<span
className="link"
onClick={() => {
onSubmitTx?.(data);
}}
>
Submit a tx
</span>{' '}
on chain to resolve
</Trans>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const TransactionItem = ({
address: maxGasTx.rawTx.from,
});
onQuickCancel?.();
message.success('Canceled');
message.success(t('page.activities.signedTx.message.cancelSuccess'));
} catch (e) {
message.error(e.message);
}
Expand All @@ -113,7 +113,7 @@ export const TransactionItem = ({
nonce: +tx.rawTx.nonce,
address: tx.rawTx.from,
});
message.success('Broadcasted');
message.success(t('page.activities.signedTx.message.broadcastSuccess'));
} catch (e) {
console.error(e);
message.error(e.message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ export const TransactionPendingTag = ({
return null;
}

if (maxGasTx.hash && !maxGasTx.reqId) {
return (
<div className="pending">
<SvgPendingSpin className="icon icon-pending-spin" />
{t('page.activities.signedTx.status.pending')}
</div>
);
}

if (maxGasTx.hash) {
return (
<Popover
Expand Down Expand Up @@ -66,9 +75,11 @@ export const TransactionPendingTag = ({
<SvgPendingSpin className="icon icon-pending-spin" />
{t('page.activities.signedTx.status.pendingBroadcast')}{' '}
<TooltipWithMagnetArrow
overlayClassName="rectangle max-w-[360px] w-[max-content]"
autoAdjustOverflow={false}
overlayClassName="rectangle max-w-[330px] w-[max-content]"
placement="top"
align={{
offset: [20, 0],
}}
title={
<>
{t('page.activities.signedTx.tips.pendingBroadcastRetry', {
Expand Down Expand Up @@ -96,9 +107,11 @@ export const TransactionPendingTag = ({
<SvgPendingSpin className="icon icon-pending-spin" />
{t('page.activities.signedTx.status.pendingBroadcast')}{' '}
<TooltipWithMagnetArrow
overlayClassName="rectangle max-w-[360px] w-[max-content]"
autoAdjustOverflow={false}
overlayClassName="rectangle max-w-[330px] w-[max-content]"
placement="top"
align={{
offset: [20, 0],
}}
title={
<>
{t('page.activities.signedTx.tips.pendingBroadcast', {
Expand Down
6 changes: 0 additions & 6 deletions src/ui/views/TransactionHistory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ const TransactionHistory = () => {
setCompleteList(completeds);
};

// useInterval(() => {
// if (pendingList.length > 0) {
// loadList();
// }
// }, 5000);

const handleTxComplete = () => {
init();
};
Expand Down

0 comments on commit b55cad4

Please sign in to comment.