Fix redemption i18n labels for Chinese UI
This commit is contained in:
@@ -45,7 +45,7 @@ const renderStatus = (status, record, t) => {
|
||||
if (isExpired(record)) {
|
||||
return (
|
||||
<Tag color='orange' shape='circle'>
|
||||
{t('Expired')}
|
||||
{t('已过期')}
|
||||
</Tag>
|
||||
);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ const renderStatus = (status, record, t) => {
|
||||
|
||||
return (
|
||||
<Tag color='black' shape='circle'>
|
||||
{t('Unknown')}
|
||||
{t('未知状态')}
|
||||
</Tag>
|
||||
);
|
||||
};
|
||||
@@ -88,7 +88,7 @@ const renderRedeemTarget = (record, t) => {
|
||||
const label = record.plan_title || `ID ${record.plan_id || '-'}`;
|
||||
return (
|
||||
<Tag color='light-green' shape='circle'>
|
||||
{`${t('Plan')}: ${label}`}
|
||||
{`${t('订阅套餐')}: ${label}`}
|
||||
</Tag>
|
||||
);
|
||||
}
|
||||
@@ -113,16 +113,16 @@ export const getRedemptionsColumns = ({
|
||||
dataIndex: 'id',
|
||||
},
|
||||
{
|
||||
title: t('Name'),
|
||||
title: t('名称'),
|
||||
dataIndex: 'name',
|
||||
},
|
||||
{
|
||||
title: t('Type'),
|
||||
title: t('类型'),
|
||||
dataIndex: 'redeem_type',
|
||||
render: (text) => <div>{renderRedeemType(text, t)}</div>,
|
||||
},
|
||||
{
|
||||
title: t('Status'),
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
render: (text, record) => {
|
||||
@@ -130,31 +130,31 @@ export const getRedemptionsColumns = ({
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('Redeem target'),
|
||||
title: t('兑换内容'),
|
||||
dataIndex: 'quota',
|
||||
render: (_, record) => {
|
||||
return <div>{renderRedeemTarget(record, t)}</div>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('Created at'),
|
||||
title: t('创建时间'),
|
||||
dataIndex: 'created_time',
|
||||
render: (text) => {
|
||||
return <div>{renderTimestamp(text)}</div>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('Expires at'),
|
||||
title: t('过期时间'),
|
||||
dataIndex: 'expired_time',
|
||||
render: (text) => {
|
||||
return <div>{text === 0 ? t('Never') : renderTimestamp(text)}</div>;
|
||||
return <div>{text === 0 ? t('永不过期') : renderTimestamp(text)}</div>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('Redeemed by'),
|
||||
title: t('兑换用户ID'),
|
||||
dataIndex: 'used_user_id',
|
||||
render: (text) => {
|
||||
return <div>{text === 0 ? t('N/A') : text}</div>;
|
||||
return <div>{text === 0 ? t('无') : text}</div>;
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -166,7 +166,7 @@ export const getRedemptionsColumns = ({
|
||||
const moreMenuItems = [
|
||||
{
|
||||
node: 'item',
|
||||
name: t('Delete'),
|
||||
name: t('删除'),
|
||||
type: 'danger',
|
||||
onClick: () => {
|
||||
showDeleteRedemptionModal(record);
|
||||
@@ -177,7 +177,7 @@ export const getRedemptionsColumns = ({
|
||||
if (record.status === REDEMPTION_STATUS.UNUSED && !isExpired(record)) {
|
||||
moreMenuItems.push({
|
||||
node: 'item',
|
||||
name: t('Disable'),
|
||||
name: t('禁用'),
|
||||
type: 'warning',
|
||||
onClick: () => {
|
||||
manageRedemption(record.id, REDEMPTION_ACTIONS.DISABLE, record);
|
||||
@@ -186,7 +186,7 @@ export const getRedemptionsColumns = ({
|
||||
} else if (!isExpired(record)) {
|
||||
moreMenuItems.push({
|
||||
node: 'item',
|
||||
name: t('Enable'),
|
||||
name: t('启用'),
|
||||
type: 'secondary',
|
||||
onClick: () => {
|
||||
manageRedemption(record.id, REDEMPTION_ACTIONS.ENABLE, record);
|
||||
@@ -203,7 +203,7 @@ export const getRedemptionsColumns = ({
|
||||
position='top'
|
||||
>
|
||||
<Button type='tertiary' size='small'>
|
||||
{t('View')}
|
||||
{t('查看')}
|
||||
</Button>
|
||||
</Popover>
|
||||
<Button
|
||||
@@ -212,7 +212,7 @@ export const getRedemptionsColumns = ({
|
||||
await copyText(record.key);
|
||||
}}
|
||||
>
|
||||
{t('Copy')}
|
||||
{t('复制')}
|
||||
</Button>
|
||||
<Button
|
||||
type='tertiary'
|
||||
@@ -223,7 +223,7 @@ export const getRedemptionsColumns = ({
|
||||
}}
|
||||
disabled={record.status !== REDEMPTION_STATUS.UNUSED}
|
||||
>
|
||||
{t('Edit')}
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
<Dropdown
|
||||
trigger='click'
|
||||
|
||||
@@ -85,7 +85,7 @@ const EditRedemptionModal = (props) => {
|
||||
.filter(Boolean);
|
||||
setSubscriptionPlans(plans);
|
||||
} else {
|
||||
showError(res.data?.message || t('Failed to load subscription plans'));
|
||||
showError(res.data?.message || t('获取订阅套餐失败'));
|
||||
}
|
||||
} catch (error) {
|
||||
showError(error.message);
|
||||
@@ -143,7 +143,7 @@ const EditRedemptionModal = (props) => {
|
||||
const selectedPlan = subscriptionPlans.find(
|
||||
(plan) => plan.id === Number(values.plan_id),
|
||||
);
|
||||
name = selectedPlan?.title || t('Subscription redemption');
|
||||
name = selectedPlan?.title || t('订阅套餐兑换码');
|
||||
} else {
|
||||
name = renderQuota(values.quota);
|
||||
}
|
||||
@@ -180,11 +180,11 @@ const EditRedemptionModal = (props) => {
|
||||
const { success, message, data } = res.data;
|
||||
if (success) {
|
||||
if (isEdit) {
|
||||
showSuccess(t('Redemption updated'));
|
||||
showSuccess(t('兑换码更新成功!'));
|
||||
props.refresh();
|
||||
props.handleClose();
|
||||
} else {
|
||||
showSuccess(t('Redemption created'));
|
||||
showSuccess(t('兑换码创建成功!'));
|
||||
props.refresh();
|
||||
formApiRef.current?.setValues(getInitValues());
|
||||
props.handleClose();
|
||||
@@ -198,11 +198,11 @@ const EditRedemptionModal = (props) => {
|
||||
text += data[i] + '\n';
|
||||
}
|
||||
Modal.confirm({
|
||||
title: t('Redemption created'),
|
||||
title: t('兑换码创建成功'),
|
||||
content: (
|
||||
<div>
|
||||
<p>{t('Download the generated redemption codes?')}</p>
|
||||
<p>{t('Codes will be downloaded as a text file named after this redemption.')}</p>
|
||||
<p>{t('兑换码创建成功,是否下载兑换码?')}</p>
|
||||
<p>{t('兑换码将以文本文件的形式下载,文件名为兑换码的名称。')}</p>
|
||||
</div>
|
||||
),
|
||||
onOk: () => {
|
||||
@@ -221,15 +221,15 @@ const EditRedemptionModal = (props) => {
|
||||
<Space>
|
||||
{isEdit ? (
|
||||
<Tag color='blue' shape='circle'>
|
||||
{t('Edit')}
|
||||
{t('更新')}
|
||||
</Tag>
|
||||
) : (
|
||||
<Tag color='green' shape='circle'>
|
||||
{t('New')}
|
||||
{t('新建')}
|
||||
</Tag>
|
||||
)}
|
||||
<Title heading={4} className='m-0'>
|
||||
{isEdit ? t('Update redemption') : t('Create redemption')}
|
||||
{isEdit ? t('更新兑换码信息') : t('创建新的兑换码')}
|
||||
</Title>
|
||||
</Space>
|
||||
}
|
||||
@@ -245,7 +245,7 @@ const EditRedemptionModal = (props) => {
|
||||
icon={<IconSave />}
|
||||
loading={loading}
|
||||
>
|
||||
{t('Submit')}
|
||||
{t('提交')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='light'
|
||||
@@ -253,7 +253,7 @@ const EditRedemptionModal = (props) => {
|
||||
onClick={handleCancel}
|
||||
icon={<IconClose />}
|
||||
>
|
||||
{t('Cancel')}
|
||||
{t('取消')}
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
@@ -283,10 +283,10 @@ const EditRedemptionModal = (props) => {
|
||||
</Avatar>
|
||||
<div>
|
||||
<Text className='text-lg font-medium'>
|
||||
{t('Basic info')}
|
||||
{t('基本信息')}
|
||||
</Text>
|
||||
<div className='text-xs text-gray-600'>
|
||||
{t('Set the redemption name, type, and expiration')}
|
||||
{t('设置兑换码的基本信息和兑换目标')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -295,13 +295,13 @@ const EditRedemptionModal = (props) => {
|
||||
<Col span={24}>
|
||||
<Form.Input
|
||||
field='name'
|
||||
label={t('Name')}
|
||||
placeholder={t('Enter a name')}
|
||||
label={t('名称')}
|
||||
placeholder={t('请输入名称')}
|
||||
style={{ width: '100%' }}
|
||||
rules={
|
||||
!isEdit
|
||||
? []
|
||||
: [{ required: true, message: t('Please enter a name') }]
|
||||
: [{ required: true, message: t('请输入名称') }]
|
||||
}
|
||||
showClear
|
||||
/>
|
||||
@@ -309,27 +309,27 @@ const EditRedemptionModal = (props) => {
|
||||
<Col span={12}>
|
||||
<Form.Select
|
||||
field='redeem_type'
|
||||
label={t('Redeem type')}
|
||||
label={t('兑换目标')}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
<Select.Option
|
||||
value={REDEMPTION_REDEEM_TYPE.QUOTA}
|
||||
>
|
||||
{t('Quota')}
|
||||
{t('额度')}
|
||||
</Select.Option>
|
||||
<Select.Option
|
||||
value={REDEMPTION_REDEEM_TYPE.SUBSCRIPTION}
|
||||
>
|
||||
{t('Subscription')}
|
||||
{t('订阅套餐')}
|
||||
</Select.Option>
|
||||
</Form.Select>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.DatePicker
|
||||
field='expired_time'
|
||||
label={t('Expires at')}
|
||||
label={t('过期时间')}
|
||||
type='dateTime'
|
||||
placeholder={t('Leave empty for no expiration')}
|
||||
placeholder={t('选择过期时间,留空为永不过期')}
|
||||
style={{ width: '100%' }}
|
||||
showClear
|
||||
/>
|
||||
@@ -338,14 +338,14 @@ const EditRedemptionModal = (props) => {
|
||||
<Col span={24}>
|
||||
<Form.Select
|
||||
field='plan_id'
|
||||
label={t('Subscription plan')}
|
||||
label={t('订阅套餐')}
|
||||
loading={plansLoading}
|
||||
placeholder={t('Select a subscription plan')}
|
||||
placeholder={t('请选择订阅套餐')}
|
||||
style={{ width: '100%' }}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t('Please select a subscription plan'),
|
||||
message: t('请选择订阅套餐'),
|
||||
},
|
||||
]}
|
||||
>
|
||||
@@ -371,12 +371,12 @@ const EditRedemptionModal = (props) => {
|
||||
</Avatar>
|
||||
<div>
|
||||
<Text className='text-lg font-medium'>
|
||||
{t('Redeem settings')}
|
||||
{t('兑换设置')}
|
||||
</Text>
|
||||
<div className='text-xs text-gray-600'>
|
||||
{redeemType === REDEMPTION_REDEEM_TYPE.SUBSCRIPTION
|
||||
? t('Choose a plan and generation count')
|
||||
: t('Set quota amount and generation count')}
|
||||
? t('设置订阅套餐和生成数量')
|
||||
: t('设置兑换码的额度和数量')}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -386,18 +386,18 @@ const EditRedemptionModal = (props) => {
|
||||
<Col span={!isEdit ? 12 : 24}>
|
||||
<Form.AutoComplete
|
||||
field='quota'
|
||||
label={t('Quota')}
|
||||
placeholder={t('Enter quota')}
|
||||
label={t('额度')}
|
||||
placeholder={t('请输入额度')}
|
||||
style={{ width: '100%' }}
|
||||
type='number'
|
||||
rules={[
|
||||
{ required: true, message: t('Please enter quota') },
|
||||
{ required: true, message: t('请输入额度') },
|
||||
{
|
||||
validator: (rule, v) => {
|
||||
const num = parseInt(v, 10);
|
||||
return num > 0
|
||||
? Promise.resolve()
|
||||
: Promise.reject(t('Quota must be greater than 0'));
|
||||
: Promise.reject(t('额度必须大于0'));
|
||||
},
|
||||
},
|
||||
]}
|
||||
@@ -426,16 +426,16 @@ const EditRedemptionModal = (props) => {
|
||||
>
|
||||
<Form.InputNumber
|
||||
field='count'
|
||||
label={t('Count')}
|
||||
label={t('生成数量')}
|
||||
min={1}
|
||||
rules={[
|
||||
{ required: true, message: t('Please enter count') },
|
||||
{ required: true, message: t('请输入生成数量') },
|
||||
{
|
||||
validator: (rule, v) => {
|
||||
const num = parseInt(v, 10);
|
||||
return num > 0
|
||||
? Promise.resolve()
|
||||
: Promise.reject(t('Count must be greater than 0'));
|
||||
: Promise.reject(t('生成数量必须大于0'));
|
||||
},
|
||||
},
|
||||
]}
|
||||
|
||||
@@ -195,7 +195,7 @@ const TopUp = () => {
|
||||
|
||||
const topUp = async () => {
|
||||
if (redemptionCode === '') {
|
||||
showInfo(t('Please enter a redemption code'));
|
||||
showInfo(t('请输入兑换码!'));
|
||||
return;
|
||||
}
|
||||
setIsSubmitting(true);
|
||||
@@ -205,18 +205,18 @@ const TopUp = () => {
|
||||
});
|
||||
const { success, message, data } = res.data;
|
||||
if (success) {
|
||||
showSuccess(t('Redemption successful'));
|
||||
showSuccess(t('兑换成功!'));
|
||||
if (data?.redeem_type === 'subscription') {
|
||||
Modal.success({
|
||||
title: t('Redemption successful'),
|
||||
content: `${t('Subscription plan redeemed: ')}${data.plan_title || data.plan_id}`,
|
||||
title: t('兑换成功!'),
|
||||
content: `${t('成功兑换订阅套餐:')}${data.plan_title || data.plan_id}`,
|
||||
centered: true,
|
||||
});
|
||||
await getSubscriptionSelf();
|
||||
} else {
|
||||
Modal.success({
|
||||
title: t('Redemption successful'),
|
||||
content: `${t('Quota redeemed: ')}${renderQuota(data?.quota || 0)}`,
|
||||
title: t('兑换成功!'),
|
||||
content: `${t('成功兑换额度:')}${renderQuota(data?.quota || 0)}`,
|
||||
centered: true,
|
||||
});
|
||||
if (userState.user) {
|
||||
@@ -232,7 +232,7 @@ const TopUp = () => {
|
||||
showError(message);
|
||||
}
|
||||
} catch (err) {
|
||||
showError(t('Request failed'));
|
||||
showError(t('请求失败'));
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user