From d10ade44e0b72d74f14343ca8bd7a424a23eff4a Mon Sep 17 00:00:00 2001 From: rjpeterson Date: Sun, 9 Jan 2022 15:32:57 -0600 Subject: [PATCH 1/3] update swap translations, remove unused "rate" from common --- components/JupiterForm.tsx | 6 ++--- components/SwapTokenInfo.tsx | 44 ++++++++++++++++++++------------ public/locales/en/common.json | 1 - public/locales/en/swap.json | 11 ++++++++ public/locales/es/common.json | 1 - public/locales/es/swap.json | 11 ++++++++ public/locales/zh/common.json | 1 - public/locales/zh/swap.json | 21 +++++++++++---- public/locales/zh_tw/common.json | 1 - public/locales/zh_tw/swap.json | 21 +++++++++++---- 10 files changed, 84 insertions(+), 34 deletions(-) diff --git a/components/JupiterForm.tsx b/components/JupiterForm.tsx index 74180596..bd8ee781 100644 --- a/components/JupiterForm.tsx +++ b/components/JupiterForm.tsx @@ -728,9 +728,9 @@ const JupiterForm: FunctionComponent = () => { (formValue?.amount / outAmountUi)) * 100 <= 0 - ? 'cheaper' - : 'more expensive' - } than CoinGecko`} + ? t('swap:cheaper') + : t('swap:more-expensive') + } CoinGecko`} ) : null} diff --git a/components/SwapTokenInfo.tsx b/components/SwapTokenInfo.tsx index f33a0cf7..9b1c8a4b 100644 --- a/components/SwapTokenInfo.tsx +++ b/components/SwapTokenInfo.tsx @@ -8,6 +8,7 @@ import { AreaChart, Area, XAxis, YAxis, Tooltip } from 'recharts' import useDimensions from 'react-cool-dimensions' import { IconButton } from './Button' import { LineChartIcon } from './icons' +import { useTranslation } from 'next-i18next' dayjs.extend(relativeTime) @@ -34,6 +35,7 @@ const SwapTokenInfo: FunctionComponent = ({ const [mouseData, setMouseData] = useState(null) const [daysToShow, setDaysToShow] = useState(1) const { observe, width, height } = useDimensions() + const { t } = useTranslation(['common', 'swap']) const handleMouseMove = (coords) => { if (coords.activePayload) { @@ -278,7 +280,7 @@ const SwapTokenInfo: FunctionComponent = ({ ) : (
- Chart not available + {t('swap:chart-not-available')}
)} @@ -351,7 +353,7 @@ const SwapTokenInfo: FunctionComponent = ({ {inputTokenInfo.market_cap_rank ? (
- Market Cap Rank + {t('swap:market-cap-rank')}
#{inputTokenInfo.market_cap_rank} @@ -360,7 +362,9 @@ const SwapTokenInfo: FunctionComponent = ({ ) : null} {inputTokenInfo.market_data?.market_cap ? (
-
Market Cap
+
+ {t('swap:market-cap')} +
$ {numberFormatter.format( @@ -371,7 +375,9 @@ const SwapTokenInfo: FunctionComponent = ({ ) : null} {inputTokenInfo.market_data.total_volume?.usd ? (
-
24h Volume
+
+ {t('daily-volume')} +
$ {numberFormatter.format( @@ -383,7 +389,7 @@ const SwapTokenInfo: FunctionComponent = ({ {inputTokenInfo.market_data?.circulating_supply ? (
- Token Supply + {t('swap:token-supply')}
{numberFormatter.format( @@ -392,7 +398,7 @@ const SwapTokenInfo: FunctionComponent = ({
{inputTokenInfo.market_data?.max_supply ? (
- Max Supply:{' '} + {t('swap:max-supply')}:{' '} {numberFormatter.format( inputTokenInfo.market_data.max_supply )} @@ -403,7 +409,7 @@ const SwapTokenInfo: FunctionComponent = ({ {inputTokenInfo.market_data?.ath?.usd ? (
- All-Time High + {t('swap:ath')}
@@ -441,7 +447,7 @@ const SwapTokenInfo: FunctionComponent = ({ {inputTokenInfo.market_data?.atl?.usd ? (
- All-Time Low + {t('swap:atl')}
@@ -488,7 +494,7 @@ const SwapTokenInfo: FunctionComponent = ({
) : (
- Input token information is not available. + {t('swap:input-info-unavailable')}
)} @@ -561,7 +567,7 @@ const SwapTokenInfo: FunctionComponent = ({ {outputTokenInfo.market_cap_rank ? (
- Market Cap Rank + {t('swap:market-cap-rank')}
#{outputTokenInfo.market_cap_rank} @@ -570,7 +576,9 @@ const SwapTokenInfo: FunctionComponent = ({ ) : null} {outputTokenInfo.market_data?.market_cap ? (
-
Market Cap
+
+ {t('swap:market-cap')} +
$ {numberFormatter.format( @@ -581,7 +589,9 @@ const SwapTokenInfo: FunctionComponent = ({ ) : null} {outputTokenInfo.market_data.total_volume?.usd ? (
-
24h Volume
+
+ {t('daily-volume')} +
$ {numberFormatter.format( @@ -593,7 +603,7 @@ const SwapTokenInfo: FunctionComponent = ({ {outputTokenInfo.market_data?.circulating_supply ? (
- Token Supply + {t('swap:token-supply')}
{numberFormatter.format( @@ -602,7 +612,7 @@ const SwapTokenInfo: FunctionComponent = ({
{outputTokenInfo.market_data?.max_supply ? (
- Max Supply:{' '} + {t('swap:max-supply')}:{' '} {numberFormatter.format( outputTokenInfo.market_data.max_supply )} @@ -613,7 +623,7 @@ const SwapTokenInfo: FunctionComponent = ({ {outputTokenInfo.market_data?.ath?.usd ? (
- All-Time High + {t('swap:ath')}
@@ -651,7 +661,7 @@ const SwapTokenInfo: FunctionComponent = ({ {outputTokenInfo.market_data?.atl?.usd ? (
- All-Time Low + {t('swap:atl')}
@@ -698,7 +708,7 @@ const SwapTokenInfo: FunctionComponent = ({
) : (
- Output token information is not available. + {t('swap:output-info-unavailable')}
)}
diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 998d5933..3f4fae32 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -272,7 +272,6 @@ "profile-menu-tip-title": "Profile Menu", "profit-price": "Profit Price", "quantity": "Quantity", - "rate": "Rate", "rates": "Deposit/Borrow Rates", "read-more": "Read More", "recent": "Recent", diff --git a/public/locales/en/swap.json b/public/locales/en/swap.json index 3d5f0bb1..5fc60f29 100644 --- a/public/locales/en/swap.json +++ b/public/locales/en/swap.json @@ -2,17 +2,27 @@ "ata-deposit": "Deposit", "ata-deposit-details": "{{cost}} SOL for {{count}} ATA Account", "ata-deposit-details_plural": "{{cost}} SOL for {{count}} ATA Accounts", + "ath": "All-Time High", + "atl": "All-Time Low", "bal": "Bal:", "best-swap": "Best Swap", + "chart-not-available": "Chart not available", + "cheaper": "cheaper than", "fees-paid-to": "Fees paid to {{feeRecipient}}", "from": "from", "get-started": "Before you get started...", "got-it": "Got It", "heres-how": "Here's how", + "input-info-unavailable": "Input token information is not available.", "jupiter-error": "Error in Jupiter – Try changing your input", + "market-cap": "Market Cap", + "market-cap-rank": "Market Cap Rank", + "max-supply": "Max Supply", "minimum-received": "Minimum Received", + "more-expensive": "more expensive than", "need-ata-account": "You need to have an Associated Token Account.", "other-routes": "{{numberOfRoutes}} other routes", + "output-info-unavailable": "Output token information is not available.", "pay": "Pay", "price-impact": "Price Impact", "price-info": "Price Info", @@ -28,6 +38,7 @@ "swap-successful": "Swap Successful", "swapping": "Swapping...", "to": "to", + "token-supply": "Token Supply", "transaction-fee": "Transaction Fee", "unavailable": "Unavailable", "you-pay": "You pay", diff --git a/public/locales/es/common.json b/public/locales/es/common.json index 93b697aa..65b39c0e 100644 --- a/public/locales/es/common.json +++ b/public/locales/es/common.json @@ -270,7 +270,6 @@ "profile-menu-tip-title": "Menú de perfil", "profit-price": "Precio de beneficio", "quantity": "Cantidad", - "rate": "Rate", "rates": "Tasas de depósito / préstamo", "read-more": "Leer más", "recent": "Reciente", diff --git a/public/locales/es/swap.json b/public/locales/es/swap.json index 209dd436..ae7ef94a 100644 --- a/public/locales/es/swap.json +++ b/public/locales/es/swap.json @@ -2,17 +2,27 @@ "ata-deposit": "Deposit", "ata-deposit-details": "{{cost}} SOL for {{count}} ATA Account", "ata-deposit-details_plural": "{{cost}} SOL for {{count}} ATA Accounts", + "ath": "All-Time High", + "atl": "All-Time Low", "bal": "Bal:", "best-swap": "Best Swap", + "chart-not-available": "Chart not available", + "cheaper": "cheaper than", "fees-paid-to": "Fees paid to {{feeRecipient}}", "from": "from", "get-started": "Before you get started...", "got-it": "Got It", "heres-how": "Here's how", + "input-info-unavailable": "Input token information is not available.", "jupiter-error": "Error in Jupiter – try changing your input", + "market-cap": "Market Cap", + "market-cap-rank": "Market Cap Rank", + "max-supply": "Max Supply", "minimum-received": "Minimum Received", + "more-expensive": "more expensive than", "need-ata-account": "You need to have an Associated Token Account.", "other-routes": "{{numberOfRoutes}} other routes", + "output-info-unavailable": "Output token information is not available.", "pay": "Pay", "price-impact": "Price Impact", "price-info": "Price Info", @@ -28,6 +38,7 @@ "swap-successful": "Swap Successful", "swapping": "Swapping...", "to": "to", + "token-supply": "Token Supply", "transaction-fee": "Transaction Fee", "unavailable": "Unavailable", "you-pay": "You pay", diff --git a/public/locales/zh/common.json b/public/locales/zh/common.json index 91375878..9c530229 100644 --- a/public/locales/zh/common.json +++ b/public/locales/zh/common.json @@ -270,7 +270,6 @@ "profile-menu-tip-title": "个人资料菜单", "profit-price": "止盈价格", "quantity": "数量", - "rate": "排放率", "rates": "存款/借贷利率", "read-more": "看更多资料", "recent": "最近", diff --git a/public/locales/zh/swap.json b/public/locales/zh/swap.json index 2220dea3..3708008a 100644 --- a/public/locales/zh/swap.json +++ b/public/locales/zh/swap.json @@ -2,32 +2,43 @@ "ata-deposit": "押金", "ata-deposit-details": "{{cost}} SOL为 {{count}} ATA帐户", "ata-deposit-details_plural": "{{cost}} SOL为 {{count}} ATA帐户", + "ath": "历史高价", + "atl": "历史低价", "bal": "余额:", - "best-swap": "Best Swap", + "best-swap": "最佳换币", + "chart-not-available": "无法显示图表", + "cheaper": "低于", "fees-paid-to": "费用缴给{{feeRecipient}}", "from": "从", "get-started": "开始前...", "got-it": "明白", "heres-how": "了解更多", + "input-info-unavailable": "获取付出币种资料时出错", "jupiter-error": "Jupiter出错,请更改输入", + "market-cap": "总市值", + "market-cap-rank": "总市值排名", + "max-supply": "最大供应量", "minimum-received": "最好获得", + "more-expensive": "高于", "need-ata-account": "您必有一个关联币种帐户(ATA)。", - "other-routes": "{{numberOfRoutes}} other routes", + "other-routes": "{{numberOfRoutes}}条其他路线", + "output-info-unavailable": "获取收到币种资料时出错", "pay": "付出", - "price-impact": "Price Impact", + "price-impact": "价格影响", "price-info": "价格细节", - "rate": "Rate", + "rate": "率", "receive": "收到", "routes-found": "找到{{numberOfRoutes}}条路线", "serum-details": "{{cost}} SOL为 {{count}} Serum OpenOrders帐户", "serum-details_plural": "{{cost}} SOL为 {{count}} Serum OpenOrders帐户", "serum-requires-openorders": "Serum要求每个币种有一个OpenOrders帐户。以后可以关闭帐户二恢复SOL押金。", - "swap-details": "Swap Details", + "swap-details": "换币细节", "swap-fee": "换币费用", "swap-in-wallet": "换币会在您被连结的钱包中进行而不在您的Mango帐户中。", "swap-successful": "交易成功", "swapping": "正在交易...", "to": "到", + "token-supply": "流通供应量", "transaction-fee": "交易费用", "unavailable": "无资料", "you-pay": "您付出", diff --git a/public/locales/zh_tw/common.json b/public/locales/zh_tw/common.json index 3011d099..7975f908 100644 --- a/public/locales/zh_tw/common.json +++ b/public/locales/zh_tw/common.json @@ -270,7 +270,6 @@ "profile-menu-tip-title": "個人資料菜單", "profit-price": "止盈價格", "quantity": "數量", - "rate": "排放率", "rates": "存款/借貸利率", "read-more": "看更多資料", "recent": "最近", diff --git a/public/locales/zh_tw/swap.json b/public/locales/zh_tw/swap.json index 421f3847..8cf603fb 100644 --- a/public/locales/zh_tw/swap.json +++ b/public/locales/zh_tw/swap.json @@ -2,32 +2,43 @@ "ata-deposit": "押金", "ata-deposit-details": "{{cost}} SOL為 {{count}} ATA帳戶", "ata-deposit-details_plural": "{{cost}} SOL為 {{count}} ATA帳戶", + "ath": "歷史高價", + "atl": "歷史低價", "bal": "餘額:", - "best-swap": "Best Swap", + "best-swap": "最佳換幣", + "chart-not-available": "無法顯示圖表", + "cheaper": "低於", "fees-paid-to": "費用繳給{{feeRecipient}}", "from": "從", "get-started": "開始前...", "got-it": "明白", "heres-how": "了解更多", + "input-info-unavailable": "獲取付出幣種資料時出錯", "jupiter-error": "Jupiter出錯,請更改輸入", + "market-cap": "總市值", + "market-cap-rank": "總市值排名", + "max-supply": "最大供應量", "minimum-received": "最好獲得", + "more-expensive": "高於", "need-ata-account": "您必有一個關聯幣種帳戶(ATA)。", - "other-routes": "{{numberOfRoutes}} other routes", + "other-routes": "{{numberOfRoutes}}條其他路線", + "output-info-unavailable": "獲取收到幣種資料時出錯", "pay": "付出", - "price-impact": "Price Impact", + "price-impact": "價格影響", "price-info": "價格細節", - "rate": "Rate", + "rate": "率", "receive": "收到", "routes-found": "找到{{numberOfRoutes}}條路線", "serum-details": "{{cost}} SOL為 {{count}} Serum OpenOrders帳戶", "serum-details_plural": "{{cost}} SOL為 {{count}} Serum OpenOrders帳戶", "serum-requires-openorders": "Serum要求每個幣種有一個OpenOrders帳戶。以後可以關閉帳戶二恢復SOL押金。", - "swap-details": "Swap Details", + "swap-details": "換幣細節", "swap-fee": "換幣費用", "swap-in-wallet": "換幣會在您被連結的錢包中進行而不在您的Mango帳戶中。", "swap-successful": "換幣成功", "swapping": "正在換幣...", "to": "到", + "token-supply": "流通供應量", "transaction-fee": "交易費用", "unavailable": "無資料", "you-pay": "您付出", From 1e7374fd3c2c8eab59dfe634145dfededd106b1f Mon Sep 17 00:00:00 2001 From: rjpeterson Date: Sun, 9 Jan 2022 16:06:05 -0600 Subject: [PATCH 2/3] add dayjs locales --- components/LanguageSwitch.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/LanguageSwitch.tsx b/components/LanguageSwitch.tsx index 01fbdc8c..69a862da 100644 --- a/components/LanguageSwitch.tsx +++ b/components/LanguageSwitch.tsx @@ -2,9 +2,15 @@ import { useEffect, useState } from 'react' import { TranslateIcon } from '@heroicons/react/outline' import DropMenu from './DropMenu' import { useRouter } from 'next/router' +import dayjs from 'dayjs' import useLocalStorageState from '../hooks/useLocalStorageState' import { useTranslation } from 'next-i18next' +require('dayjs/locale/en') +require('dayjs/locale/es') +require('dayjs/locale/zh') +require('dayjs/locale/zh-tw') + export const LANGS = [ { locale: 'en', name: 'english', description: 'english' }, { locale: 'es', name: 'spanish', description: 'spanish' }, @@ -29,6 +35,7 @@ const LanguageSwitch = () => { const handleLangChange = (e) => { setSavedLanguage(e) router.push({ pathname, query }, asPath, { locale: e }) + dayjs.locale(e == 'zh_tw' ? 'zh-tw' : e) } return ( From 0663c321e446c2ea85659407a5873490a0a2befd Mon Sep 17 00:00:00 2001 From: rjpeterson Date: Sun, 9 Jan 2022 16:31:56 -0600 Subject: [PATCH 3/3] add missed translations. rename common:slippage key --- components/SwapSettingsModal.tsx | 10 ++++++---- components/trade_form/EstPriceImpact.tsx | 2 +- pages/swap.tsx | 8 ++++---- public/locales/en/common.json | 6 +++--- public/locales/en/swap.json | 3 +++ public/locales/es/common.json | 6 +++--- public/locales/es/swap.json | 3 +++ public/locales/zh/common.json | 6 +++--- public/locales/zh/swap.json | 3 +++ public/locales/zh_tw/common.json | 6 +++--- public/locales/zh_tw/swap.json | 3 +++ 11 files changed, 35 insertions(+), 21 deletions(-) diff --git a/components/SwapSettingsModal.tsx b/components/SwapSettingsModal.tsx index 84b6e0ea..c879986a 100644 --- a/components/SwapSettingsModal.tsx +++ b/components/SwapSettingsModal.tsx @@ -19,7 +19,7 @@ const SwapSettingsModal = ({ slippage: number setSlippage: (x) => void }) => { - const { t } = useTranslation('common') + const { t } = useTranslation(['common', 'swap']) const [tempSlippage, setTempSlippage] = useState(slippage) const [inputValue, setInputValue] = useState( tempSlippage ? tempSlippage.toString() : '' @@ -45,10 +45,12 @@ const SwapSettingsModal = ({ return ( -

Slippage Settings

+

+ {t('swap:slippage-settings')} +

-
Slippage
+
{t('swap:slippage')}
setShowCustomSlippageForm(!showCustomSlippageForm)} @@ -75,7 +77,7 @@ const SwapSettingsModal = ({ /> )} ) diff --git a/components/trade_form/EstPriceImpact.tsx b/components/trade_form/EstPriceImpact.tsx index 95487e12..14562262 100644 --- a/components/trade_form/EstPriceImpact.tsx +++ b/components/trade_form/EstPriceImpact.tsx @@ -13,7 +13,7 @@ const EstPriceImpact = ({ return (
- {t('slippage')} + {t('est-slippage')} - Swap + {t('swap')}

- Swap between 100s of tokens at the best rates. + {t('swap:swap-between-hundreds')}