Skip to content

Commit

Permalink
feat(neuron-ui): update the i18n texts of nervos dao.
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Nov 16, 2019
1 parent 53b13da commit b445a0c
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 43 deletions.
4 changes: 2 additions & 2 deletions packages/neuron-ui/src/components/CustomRows/DAORecordRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const DAORecord = ({
metaInfo = t('nervos-dao.blocks-left', {
epochs: localNumberFormatter(epochs),
blocks: localNumberFormatter(currentEpochInfo.length - currentEpochInfo.index),
days: localNumberFormatter(epochs / BigInt(6)),
days: localNumberFormatter(Math.round(Number(epochs) / 6)),
})
}
}
Expand Down Expand Up @@ -153,7 +153,7 @@ const DAORecord = ({
</div>
<div className={styles.secondaryInfo}>
<span>{`APC: ~${apc}%`}</span>
<span>{uniformTimeFormatter(+timestamp)}</span>
<span>{t('nervos-dao.deposit-at', { time: uniformTimeFormatter(+timestamp) })}</span>
<span>{metaInfo}</span>
</div>
</div>
Expand Down
40 changes: 30 additions & 10 deletions packages/neuron-ui/src/components/NervosDAO/DepositDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { useMemo } from 'react'
import {
Stack,
Dialog,
Expand All @@ -7,13 +7,15 @@ import {
Text,
DefaultButton,
PrimaryButton,
ActionButton,
DialogType,
DialogFooter,
Spinner,
SpinnerSize,
} from 'office-ui-fabric-react'
import { useTranslation } from 'react-i18next'
import { SHANNON_CKB_RATIO } from 'utils/const'
import { useTranslation, Trans } from 'react-i18next'
import { SHANNON_CKB_RATIO, NERVOS_DAO_RFC_URL } from 'utils/const'
import { openExternal } from 'services/remote'

const DepositDialog = ({
show,
Expand All @@ -28,6 +30,28 @@ const DepositDialog = ({
errorMessage,
}: any) => {
const [t] = useTranslation()
const rfcLink = useMemo(
() => (
<ActionButton
styles={{
root: {
height: 20,
margin: 0,
padding: 0,
textDecoration: 'underline',
fontSize: 14,
color: 'rgb(0, 120, 212)',
},
label: {
margin: 0,
},
}}
onClick={() => openExternal(NERVOS_DAO_RFC_URL)}
ariaLabel="Nervos DAO RFC"
/>
),
[]
)
const maxValue = +(BigInt(balance) / BigInt(SHANNON_CKB_RATIO)).toString()

if (!show) {
Expand Down Expand Up @@ -63,13 +87,9 @@ const DepositDialog = ({
<Text as="h2" variant="large">
{`${t('nervos-dao.notice')}:`}
</Text>
{t('nervos-dao.deposit-terms')
.split('\n')
.map(term => (
<Text as="p" key={term}>
{term}
</Text>
))}
<Text as="p">
<Trans i18nKey="nervos-dao.deposit-terms" components={[rfcLink]} />
</Text>
</Stack>
<DialogFooter>
<DefaultButton onClick={onDismiss} text={t('nervos-dao.cancel')} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,17 @@ const WithdrawDialog = ({
? t('nervos-dao.notice-wait-time', {
epochs: localNumberFormatter(epochs),
blocks: localNumberFormatter(currentEpochInfo.length - currentEpochInfo.index),
days: localNumberFormatter(epochs / BigInt(6)),
days: localNumberFormatter(Math.round(Number(epochs) / 6)),
})
: ''

const alert =
epochs <= BigInt(5) && epochs >= BigInt(0)
? t('nervos-dao.withdraw-alert', {
epochs,
hours: epochs * BigInt(4),
days: (epochs + BigInt(180)) / BigInt(6),
epochs: localNumberFormatter(epochs),
hours: localNumberFormatter(epochs * BigInt(4)),
nextLeftEpochs: localNumberFormatter(epochs + BigInt(180)),
days: localNumberFormatter(Math.round((Number(epochs) + 180) / 6)),
})
: ''

Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/src/components/NervosDAO/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ const NervosDAO = ({
return (
<>
<Text as="h2" variant="xxLarge">
{t('nervos-dao.deposit-receipts')}
{t('nervos-dao.deposit-records')}
</Text>
<Stack>
{records.map((record, i) => {
Expand Down
21 changes: 9 additions & 12 deletions packages/neuron-ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,29 +319,26 @@
"free": "Free",
"locked": "Locked",
"deposit": "Deposit",
"deposit-receipts": "Deposit Receipts",
"deposit-records": "Deposit Records",
"apc": "APC",
"deposit-at": "Deposit at {{time}}",
"claim": "Claim",
"withdraw": "Withdraw",
"fee": "Transaction fee",
"deposit-to-nervos-dao": "Deposit to Nervos DAO",
"withdraw-from-nervos-dao": "Withdraw from Nervos DAO",
"notice": "Notice",
"cancel": "Cancel",
"proceed": "Proceed",
"deposit-value": "Deposit",
"compensation": "Compensation",
"notice-wait-time": "Notice: You need to wait {{epochs}} epochs {{blocks}} blocks(~{{days}} days) to claim the saving.",
"deposit-terms": "Nervos DAO needs 102 CKB for receipt storage, which is not compensation-bearing.\nNervos DAO is a system layer decentralized infrastructure. Your saving here is secure.\nAccording to the Nervos DAO protocol, you need at least 180 epochs to withdraw your deposit.",
"deposited-action-label": "Withdraw",
"withdrawing-action-label": "Claim",
"minimal-fee-required": "The minimum deposit capacity is {{minimal}} CKB",
"notice-wait-time": "Notice: You need to wait {{epochs}} epochs {{blocks}} blocks(~{{days}} days) to complete the withdraw.",
"deposit-terms": "Nervos DAO needs 102 CKBytes for deposit cell storage, which is not compensation-bearing. Please visit the <0>Nervos DAO RFC</0> for more information about Nervos DAO",
"deposited-action-label": "Request withdraw",
"withdrawing-action-label": "Withdraw",
"minimal-fee-required": "The minimum deposit capacity is {{minimal}} CKBytes",
"compensation-accumulated": "{{blockNumber}} blocks compensation accumulated",
"blocks-left": "{{epochs}} epochs {{blocks}} blocks left(~{{days}} days)",
"withdraw-alert": "Hint: these are only {{epochs}} epochs (~{{hours}} hours) left to the next deposit claim period. If your start withdrawing transaction is not confirmed before that, your deposit will be locked until the next period (~{{days}} days). And you won’t get more compensation for the prolonged lock period.",
"insufficient-period-alert-title": "Insufficient Period",
"insufficient-period-alert-message": "Nervos DAO needs at least 4 epochs to handle your request."
"withdraw-alert": "Hint: these are only {{epochs}} epochs (~{{hours}} hours) until the end of your current lock period. If you wish to withdraw in current lock period, please send withdraw request in time. There are {{nextLeftEpochs}} epochs(~{{days}} days) until the end of your next lock period.",
"insufficient-period-alert-title": "Referenced Header is Invalid",
"insufficient-period-alert-message": "Only mature header can be referenced in transactions(Matureness requires 4 epochs)"
}
}
}
25 changes: 11 additions & 14 deletions packages/neuron-ui/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,29 +319,26 @@
"free": "当前可用",
"locked": "已锁定",
"deposit": "存入",
"deposit-receipts": "存款凭证",
"deposit-records": "锁定记录",
"apc": "年化锁定补贴率",
"deposit-at": "存入于{{time}}",
"claim": "取款",
"withdraw": "结算",
"deposit-at": "存入于 {{time}}",
"fee": "手续费",
"deposit-to-nervos-dao": "存入 Nervos DAO",
"withdraw-from-nervos-dao": "从 Nervos DAO 取出",
"notice": "注意",
"cancel": "取消",
"proceed": "继续",
"deposit-value": "存款",
"compensation": "锁定补贴",
"notice-wait-time": "注意: 您需要等待 {{epochs}} epochs {{blocks}} 区块(~{{days}}天)完成最终取款",
"deposit-terms": "存入 NervosDAO 的资产中需要 102 CKB 作为存款凭证的存储,这部分 CKB 是无法产生锁定补贴的。\nNervos DAO 是一个系统层面的去中心化底层设施。您在其中存款是十分安全的。\n根据 Nervos DAO 的协议, 您需要等待至少 180 个 epochs 才能取回您的存款",
"deposited-action-label": "结算",
"withdrawing-action-label": "取款",
"minimal-fee-required": "存入金额应不少于 {{minimal}} CKB",
"notice-wait-time": "注意: 您需要等待 {{epochs}} epochs {{blocks}} 区块({{days}} 天)完成最终取出操作",
"deposit-terms": "Nervos DAO 需要 102 CKBytes 作为锁定记录的存储,这部分 CKBytes 是无法产生锁定补贴的。请查看 <0>Nervos DAO RFC</0> 以了解 Nervos DAO 更多信息",
"deposited-action-label": "申请取出",
"withdrawing-action-label": "取出",
"minimal-fee-required": "存入数量应不少于 {{minimal}} CKBytes",
"compensation-accumulated": "已累计 {{blockNumber}} 个块的锁定补贴",
"blocks-left": " 还需等待 {{epochs}} epochs {{blocks}} 个块(~{{days}} 天)",
"withdraw-alert": "提示:本补贴申请距离 Nervos DAO 规则允许的最近一个撤出周期仅剩下 {{epochs}} 个 epoch (约 {{hours}} 小时),存在交易拥堵无法上链从而导致只能在下一个撤出周期(约 {{days}} 天)撤出,且无法获得新增撤出周期期间补偿的可能",
"insufficient-period-alert-title": "未达到要求周期",
"insufficient-period-alert-message": "Nervos DAO 要求您在至少 4 个 epochs 后执行此操作"
"blocks-left": " 还需等待 {{epochs}} epochs {{blocks}} 个块({{days}} 天)",
"withdraw-alert": "提示:本补贴申请距离 Nervos DAO 规则允许的最近一个锁定周期仅剩下 {{epochs}} 个 epoch (约 {{hours}} 小时)。 如果您希望在本锁定周期取出,请及时提交取出申请,以确保取出申请能在本锁定周期结束之前上链。下一个锁定周期的结束时间预计为 {{nextLeftEpochs}} 个 epochs (约 {{days}} 天)。",
"insufficient-period-alert-title": "Header 引用无效",
"insufficient-period-alert-message": "交易只能引用已成熟的 Header(成熟期为 4 个 epochs)"
}
}
}
2 changes: 2 additions & 0 deletions packages/neuron-ui/src/utils/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export const MEDIUM_FEE_RATE = 6000
export const WITHDRAW_EPOCHS = 180

export const RUN_NODE_GUIDE_URL = 'https://docs.nervos.org/references/neuron-wallet-guide.html#1-run-a-ckb-mainnet-node'
export const NERVOS_DAO_RFC_URL =
'https://github.com/nervosnetwork/rfcs/tree/master/rfcs/0000-dao-deposit-withdraw/0000-dao-deposit-withdraw.md'

export enum ConnectionStatus {
Online = 'online',
Expand Down

0 comments on commit b445a0c

Please sign in to comment.