From b9e9a955f26e1ebf9f45fd951fbbfe295f487c85 Mon Sep 17 00:00:00 2001 From: PuerNya Date: Mon, 18 Sep 2023 13:45:15 +0800 Subject: [PATCH] feat: show provider expire message with i18n (#237) --- src/components/SubscriptionInfo.tsx | 16 ++++++++++++++-- src/i18n/en.ts | 2 ++ src/i18n/zh.ts | 2 ++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/components/SubscriptionInfo.tsx b/src/components/SubscriptionInfo.tsx index 5adb83f..4171de7 100644 --- a/src/components/SubscriptionInfo.tsx +++ b/src/components/SubscriptionInfo.tsx @@ -1,3 +1,4 @@ +import { useI18n } from '@solid-primitives/i18n' import byteSize from 'byte-size' import dayjs from 'dayjs' import { toFinite } from 'lodash' @@ -12,9 +13,17 @@ const getSubscriptionsInfo = (subscriptionInfo: ISubscriptionInfo) => { }) const percentage = toFinite((((Download + Upload) / Total) * 100).toFixed(2)) + const expirePrefix = () => { + const [t] = useI18n() + + return t('expire') + } + const expireStr = () => { + const [t] = useI18n() + if (Expire === 0) { - return 'Null' + return t('noExpire') } return dayjs(Expire * 1000).format('YYYY-MM-DD') @@ -24,6 +33,7 @@ const getSubscriptionsInfo = (subscriptionInfo: ISubscriptionInfo) => { total, used, percentage, + expirePrefix, expireStr, } } @@ -45,7 +55,9 @@ export const SubscriptionInfo = (props: { {`${info.used}`} / {`${info.total}`} ( {info.percentage}% ) -
Expire: {info.expireStr()}
+
+ {info.expirePrefix()}: {info.expireStr()} +
) } diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 0766eb7..34f9311 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -94,4 +94,6 @@ export default { coreConfig: 'Core Config', xdConfig: 'XD Config', version: 'Version', + expire: 'Expire', + noExpire: 'Null', } diff --git a/src/i18n/zh.ts b/src/i18n/zh.ts index 74171ad..3436e29 100644 --- a/src/i18n/zh.ts +++ b/src/i18n/zh.ts @@ -94,4 +94,6 @@ export default { coreConfig: '核心配置', xdConfig: 'XD 配置', version: '版本', + expire: '到期时间', + noExpire: '不限时', }