Skip to content

Commit 5804d34

Browse files
committed
refactor: update translations for balance components in user-[userId] context
1 parent 7b90c90 commit 5804d34

15 files changed

+139
-94
lines changed

messages/en.json

+8-6
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,10 @@
650650
},
651651
"user-[userId]-balance": {
652652
"available_balance": "Available Balance",
653-
"earnings_amount": "Earnings Amount"
653+
"balance": "Balance",
654+
"earnings": "Earnings",
655+
"earnings_amount": "Earnings Amount",
656+
"check_your_account_balance": "Check your account balance"
654657
},
655658
"user-[userId]-balance-log": {
656659
"balance": "Balance",
@@ -681,17 +684,17 @@
681684
"recharge_code": "Recharge Code"
682685
},
683686
"user-[userId]-recharge-depay": {
684-
"after_clicking_confirm": "After clicking confirm",
685687
"and": "and",
686688
"confirm": "Confirm",
687-
"enter_crypto_wallet_select_payment_method": "you will enter the crypto wallet to select a payment method",
688689
"invalid_amount": "Invalid amount",
689690
"minimum_recharge_amount": "Minimum recharge amount",
690691
"notes": "Notes",
692+
"note_1": "Supports <important>USDC</important> and <important>USDT</important> recharge, with a minimum recharge amount of ${rechargeMinAmount}",
693+
"note_2": "After clicking Confirm, you will enter the encrypted wallet to select the payment method.",
694+
"note_3": "Top-ups are subject to a 1.5% fee.",
691695
"recharge": "Recharge",
692696
"recharge_amount": "Recharge Amount",
693697
"recharge_failed": "Recharge Failed",
694-
"recharge_handling_fee": "Recharge requires a handling fee of",
695698
"recharge_successful": "Recharge Successful",
696699
"support": "Support",
697700
"supported_networks": "Supported networks"
@@ -712,8 +715,7 @@
712715
"please_provide": "Please provide",
713716
"receiving_address": "Receiving Address",
714717
"request_withdrawal": "Request Withdrawal",
715-
"request_withdrawal_to_specified_address": "Request withdrawal to the specified address",
716-
"subject_to_actual_received_amount": "Subject to the actual received amount",
718+
"request_withdrawal_desc": "When applying for withdrawal to the designated address, part of the handling fee needs to be deducted, and the actual amount received shall prevail.",
717719
"withdrawal": "Withdrawal"
718720
}
719721
}

messages/zh.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,10 @@
650650
},
651651
"user-[userId]-balance": {
652652
"available_balance": "可消费余额",
653-
"earnings_amount": "收益金额"
653+
"balance": "余额",
654+
"earnings": "收益",
655+
"earnings_amount": "收益金额",
656+
"check_your_account_balance": "查看你的账户余额"
654657
},
655658
"user-[userId]-balance-log": {
656659
"balance": "余额",
@@ -681,17 +684,17 @@
681684
"recharge_code": "充值码"
682685
},
683686
"user-[userId]-recharge-depay": {
684-
"after_clicking_confirm": "点击确认后",
685687
"and": "",
686688
"confirm": "确认",
687-
"enter_crypto_wallet_select_payment_method": "将会进入加密钱包选择支付方式",
688689
"invalid_amount": "无效的金额",
689690
"minimum_recharge_amount": "充值金额最低",
690691
"notes": "注意事项",
692+
"note_1": "支持 <b>USDC</b> 和 <b>USDT</b> 充值,充值金额最低 ${rechargeMinAmount}",
693+
"note_2": "点击确认后,将会进入加密钱包选择支付方式。",
694+
"note_3": "充值需要收取 1.5% 的手续费。",
691695
"recharge": "充值",
692696
"recharge_amount": "充值金额",
693697
"recharge_failed": "充值失败",
694-
"recharge_handling_fee": "充值需要收取",
695698
"recharge_successful": "充值成功",
696699
"support": "支持",
697700
"supported_networks": "支持的网络"
@@ -707,13 +710,11 @@
707710
"user-[userId]-withdrawal-balance": {
708711
"amount": "金额",
709712
"current_earnings_balance": "当前收益余额",
710-
"deduct_handling_fee": "需要扣除部分手续费",
711713
"minimum_withdrawal_amount": "最低提现金额为",
712714
"please_provide": "请提供",
713715
"receiving_address": "收款地址",
714716
"request_withdrawal": "申请提现",
715-
"request_withdrawal_to_specified_address": "申请提现到指定的地址",
716-
"subject_to_actual_received_amount": "以实际到账金额为准",
717+
"request_withdrawal_desc": "申请提现到指定的地址,需要扣除部分手续费,以实际到账金额为准",
717718
"withdrawal": "提现"
718719
}
719720
}

src/app/[local]/(manage)/user/[userId]/_components/balance-log.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "~/lib/ui/tooltip";
99
import type { RouterOutputs } from "~/trpc/shared";
1010
import { MoneyInput } from "~/lib/ui/money-input";
1111
import { type BalanceType } from "@prisma/client";
12+
import { useTranslations } from "use-intl";
1213

1314
export default function BalanceLog({
1415
userId,
@@ -17,6 +18,7 @@ export default function BalanceLog({
1718
userId: string;
1819
balanceType?: BalanceType;
1920
}) {
21+
const t = useTranslations("user-[userId]-balance-log");
2022
const getLogs = api.user.getBalanceLogs.useInfiniteQuery(
2123
{
2224
id: userId,
@@ -105,15 +107,15 @@ export default function BalanceLog({
105107

106108
return (
107109
<Card>
108-
<CardHeader>余额历史</CardHeader>
110+
<CardHeader>{t("balance_history")}</CardHeader>
109111
<CardContent>
110112
<div className="border-b">
111113
<div className="flex space-x-2 py-1 text-left text-sm text-muted-foreground">
112-
<div className="w-[170px]">时间</div>
114+
<div className="w-[170px]">{t("time")}</div>
113115
<div className="grid flex-1 grid-cols-4 gap-2">
114-
<p>变动金额</p>
115-
<p>余额</p>
116-
<p className="col-span-2">其它信息</p>
116+
<p>{t("change_amount")}</p>
117+
<p>{t("balance")}</p>
118+
<p className="col-span-2">{t("other_info")}</p>
117119
</div>
118120
</div>
119121
</div>

src/app/[local]/(manage)/user/[userId]/_components/balance.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import RechargeBalance from "~/app/[local]/(manage)/user/[userId]/_components/re
77
import { MoneyInput } from "~/lib/ui/money-input";
88
import { BalanceType } from "@prisma/client";
99
import WithdrawalBalance from "~/app/[local]/(manage)/user/[userId]/_components/withdrawal-balance";
10+
import { useTranslations } from "use-intl";
1011

1112
interface BalanceProps {
1213
wallet: {
@@ -18,13 +19,13 @@ interface BalanceProps {
1819

1920
export default function Balance({ wallet, userId }: BalanceProps) {
2021
const { data: session } = useSession();
21-
22+
const t = useTranslations("user-[userId]-balance");
2223
return (
2324
<Card>
2425
<CardHeader>
2526
{wallet?.balanceType === BalanceType.CONSUMPTION
26-
? "可消费余额"
27-
: "收益金额"}
27+
? t("available_balance")
28+
: t("earnings_amount")}
2829
</CardHeader>
2930
<CardContent>
3031
<MoneyInput displayType="text" value={wallet?.balance} />

src/app/[local]/(manage)/user/[userId]/_components/profile-form.tsx

+9-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { Button } from "~/lib/ui/button";
1818
import { useEffect, useState } from "react";
1919
import { type RouterOutputs } from "~/trpc/shared";
2020
import { useTrack } from "~/lib/hooks/use-track";
21+
import { useTranslations } from "use-intl";
2122

2223
const updateProfileFormSchema = z.object({
2324
name: z.string().min(1).max(255).optional(),
@@ -29,6 +30,7 @@ export default function ProfileForm({
2930
}: {
3031
user: RouterOutputs["user"]["getOne"];
3132
}) {
33+
const t = useTranslations("user-[userId]-profile-form");
3234
const updateProfileMutation = api.user.updateProfile.useMutation();
3335
const { track } = useTrack();
3436
const form = useForm<z.infer<typeof updateProfileFormSchema>>({
@@ -68,11 +70,13 @@ export default function ProfileForm({
6870
name="name"
6971
render={({ field }) => (
7072
<FormItem>
71-
<FormLabel>名称</FormLabel>
73+
<FormLabel>{t("name")}</FormLabel>
7274
<FormControl>
7375
<Input {...field} />
7476
</FormControl>
75-
<FormDescription>显示在您的个人资料中的名称</FormDescription>
77+
<FormDescription>
78+
{t("name_displayed_in_profile")}
79+
</FormDescription>
7680
<FormMessage />
7781
</FormItem>
7882
)}
@@ -82,11 +86,11 @@ export default function ProfileForm({
8286
name="image"
8387
render={({ field }) => (
8488
<FormItem>
85-
<FormLabel>头像</FormLabel>
89+
<FormLabel>{t("avatar")}</FormLabel>
8690
<FormControl>
8791
<Input {...field} />
8892
</FormControl>
89-
<FormDescription>头像链接</FormDescription>
93+
<FormDescription>{t("avatar_link")}</FormDescription>
9094
<FormMessage />
9195
</FormItem>
9296
)}
@@ -98,7 +102,7 @@ export default function ProfileForm({
98102
loading={updateProfileMutation.isLoading}
99103
success={updateProfileMutation.isSuccess}
100104
>
101-
保存
105+
{t("save")}
102106
</Button>
103107
</div>
104108
</form>

src/app/[local]/(manage)/user/[userId]/_components/recharge-balance.tsx

+12-8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { api } from "~/trpc/react";
1414
import React, { useState } from "react";
1515
import dynamic from "next/dynamic";
1616
import { useTrack } from "~/lib/hooks/use-track";
17+
import { useTranslations } from "use-intl";
1718

1819
const RechargeDepay = dynamic(() => import("./recharge-depay"), {
1920
ssr: false,
@@ -28,6 +29,7 @@ const RechargeDepay = dynamic(() => import("./recharge-depay"), {
2829
});
2930

3031
export default function RechargeBalance({ userId }: { userId: string }) {
32+
const t = useTranslations("user-[userId]-recharge-balance");
3133
const [code, setCode] = useState("");
3234
const rechargeBalanceByCodeMutation =
3335
api.user.rechargeBalanceByCode.useMutation();
@@ -38,27 +40,29 @@ export default function RechargeBalance({ userId }: { userId: string }) {
3840
<DialogTrigger asChild>
3941
<Button>
4042
<GemIcon className="mr-2 h-5 w-5" />
41-
充值
43+
{t("recharge")}
4244
</Button>
4345
</DialogTrigger>
4446
<DialogContent className="h-full w-full md:h-auto md:min-w-20">
4547
<DialogHeader>
46-
<DialogTitle>余额充值</DialogTitle>
48+
<DialogTitle>{t("balance_recharge")}</DialogTitle>
4749
</DialogHeader>
4850
<Tabs defaultValue="recharge">
4951
<TabsList className="grid w-full grid-cols-2">
50-
<TabsTrigger value="recharge">充值</TabsTrigger>
51-
<TabsTrigger value="recharge_code">充值码</TabsTrigger>
52+
<TabsTrigger value="recharge">{t("recharge")}</TabsTrigger>
53+
<TabsTrigger value="recharge_code">
54+
{t("recharge_code")}
55+
</TabsTrigger>
5256
</TabsList>
53-
<TabsContent value={"recharge"} className="h-[570px]">
57+
<TabsContent value={"recharge"} className="h-[600px]">
5458
<RechargeDepay />
5559
</TabsContent>
5660
<TabsContent value="recharge_code">
5761
<div className="mb-4">
58-
<Label>充值码</Label>
62+
<Label>{t("recharge_code")}</Label>
5963
<div className="mt-1">
6064
<Input
61-
placeholder="请输入充值码"
65+
placeholder={t("enter_recharge_code")}
6266
value={code}
6367
onChange={(e) => setCode(e.target.value)}
6468
/>
@@ -80,7 +84,7 @@ export default function RechargeBalance({ userId }: { userId: string }) {
8084
loading={rechargeBalanceByCodeMutation.isLoading}
8185
success={rechargeBalanceByCodeMutation.isSuccess}
8286
>
83-
充值
87+
{t("recharge")}
8488
</Button>
8589
</div>
8690
</TabsContent>

src/app/[local]/(manage)/user/[userId]/_components/recharge-depay.tsx

+19-16
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { type RouterOutputs } from "~/trpc/shared";
1111
import Image from "next/image";
1212
import Blockchains from "@depay/web3-blockchains";
1313
import { useTrack } from "~/lib/hooks/use-track";
14+
import { useTranslations } from "use-intl";
1415

1516
const dePayWidgetStyles = `
1617
.PoweredByWrapper {
@@ -39,6 +40,7 @@ const dePayWidgetStyles = `
3940
`;
4041

4142
export default function RechargeDepay() {
43+
const t = useTranslations("user-[userId]-recharge-depay");
4244
const dePayRef = useRef(null);
4345
const [amount, setAmount] = useState("0");
4446
const [dePay, setDePay] = useState<{
@@ -78,15 +80,15 @@ export default function RechargeDepay() {
7880
amount: data.amount,
7981
});
8082
toast({
81-
title: "充值成功",
82-
description: `充值金额 ${data.amount} USDC/USDT`,
83+
title: t("recharge_successful"),
84+
description: `${t("recharge_amount")} ${data.amount} USDC/USDT`,
8385
});
8486
} else if (data?.status === "FAILED") {
8587
track("recharge-depay-fail", {
8688
amount: data.amount,
8789
});
8890
toast({
89-
title: "充值失败",
91+
title: t("recharge_failed"),
9092
variant: "destructive",
9193
});
9294
}
@@ -118,7 +120,7 @@ export default function RechargeDepay() {
118120
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
119121
// @ts-expect-error
120122
const configuration: DePayWidgets.PaymentOptions = {
121-
title: "充值",
123+
title: t("recharge"),
122124
container: dePayRef.current,
123125
integration: dePayIntegrationId,
124126
payload: payload,
@@ -165,8 +167,8 @@ export default function RechargeDepay() {
165167
const amountNumber = parseFloat(amount);
166168
if (isNaN(amountNumber) || amountNumber < rechargeMinAmount) {
167169
toast({
168-
title: "无效的金额",
169-
description: `充值金额最低 ${rechargeMinAmount} USDC/USDT`,
170+
title: t("invalid_amount"),
171+
description: `${t("recharge_amount")} ${rechargeMinAmount} USDC/USDT`,
170172
variant: "destructive",
171173
});
172174
return;
@@ -191,7 +193,7 @@ export default function RechargeDepay() {
191193
{!dePay.loaded && (
192194
<>
193195
<div className="space-y-4">
194-
<Label>充值金额</Label>
196+
<Label>{t("recharge_amount")}</Label>
195197
<MoneyInput
196198
value={amount}
197199
onValueChange={(values) => {
@@ -201,21 +203,22 @@ export default function RechargeDepay() {
201203
<Button onClick={() => createPayment()} className="w-full">
202204
<TetherIcon className="mr-2 h-5 w-5" />
203205
<USDCIcon className="mr-2 h-5 w-5" />
204-
确认
206+
{t("confirm")}
205207
</Button>
206208
</div>
207209
<div className="space-y-4">
208-
<h3 className="mt-4 text-lg font-semibold">注意事项</h3>
210+
<h3 className="mt-4 text-lg font-semibold">{t("notes")}</h3>
209211
<p className="text-sm">
210-
1. 支持 <b>USDC</b><b>USDT</b> 充值,充值金额最低 $
211-
{rechargeMinAmount}
212+
1.{" "}
213+
{t.rich("note_1", {
214+
important: (children) => <b>{children}</b>,
215+
rechargeMinAmount: rechargeMinAmount,
216+
})}
212217
</p>
213-
<p className="text-sm">
214-
2. 点击确认后,将会进入加密钱包选择支付方式。
215-
</p>
216-
<p className="text-sm">3. 充值需要收取 1.5% 的手续费。</p>
218+
<p className="text-sm">2. {t("note_2")}</p>
219+
<p className="text-sm">3. {t("note_3")}</p>
217220
<div>
218-
<p className="text-md mb-2">支持的网络</p>
221+
<p className="text-md mb-2">{t("supported_networks")}</p>
219222
<ul className="space-y-2">
220223
{[
221224
Blockchains.avalanche,

0 commit comments

Comments
 (0)