fix: public note i18n

This commit is contained in:
hamster1963 2024-12-21 19:17:32 +08:00
parent a8c7253bf8
commit c600b81520
4 changed files with 49 additions and 9 deletions

View File

@ -1,8 +1,10 @@
import { PublicNoteData, cn, getDaysBetweenDatesWithAutoRenewal } from "@/lib/utils"
import { useTranslation } from "react-i18next"
import RemainPercentBar from "./RemainPercentBar"
export default function BillingInfo({ parsedData }: { parsedData: PublicNoteData }) {
const { t } = useTranslation()
if (!parsedData || !parsedData.billingDataMod) {
return null
}
@ -22,36 +24,44 @@ export default function BillingInfo({ parsedData }: { parsedData: PublicNoteData
daysLeftObject = getDaysBetweenDatesWithAutoRenewal(parsedData.billingDataMod)
} catch (error) {
console.error(error)
return <div className={cn("text-[10px] text-muted-foreground text-red-600")}>剩余时间: 计算出错</div>
return (
<div className={cn("text-[10px] text-muted-foreground text-red-600")}>
{t("billingInfo.remaining")}: {t("billingInfo.error")}
</div>
)
}
}
}
return daysLeftObject.days >= 0 ? (
<>
<div className={cn("text-[10px] text-muted-foreground")}>: {isNeverExpire ? "永久" : daysLeftObject.days + "天"}</div>
<div className={cn("text-[10px] text-muted-foreground")}>
{t("billingInfo.remaining")}: {isNeverExpire ? t("billingInfo.indefinite") : daysLeftObject.days + " " + t("billingInfo.days")}
</div>
{parsedData.billingDataMod.amount && parsedData.billingDataMod.amount !== "0" && parsedData.billingDataMod.amount !== "-1" ? (
<p className={cn("text-[10px] text-muted-foreground ")}>
: {parsedData.billingDataMod.amount}/{parsedData.billingDataMod.cycle}
{t("billingInfo.price")}: {parsedData.billingDataMod.amount}/{parsedData.billingDataMod.cycle}
</p>
) : parsedData.billingDataMod.amount === "0" ? (
<p className={cn("text-[10px] text-green-600 ")}></p>
<p className={cn("text-[10px] text-green-600 ")}>{t("billingInfo.free")}</p>
) : parsedData.billingDataMod.amount === "-1" ? (
<p className={cn("text-[10px] text-pink-600 ")}></p>
<p className={cn("text-[10px] text-pink-600 ")}>{t("billingInfo.usage-baseed")}</p>
) : null}
<RemainPercentBar className="mt-0.5" value={daysLeftObject.remainingPercentage * 100} />
</>
) : (
<>
<p className={cn("text-[10px] text-muted-foreground text-red-600")}>: {daysLeftObject.days * -1} </p>
<p className={cn("text-[10px] text-muted-foreground text-red-600")}>
{t("billingInfo.expired")}: {daysLeftObject.days * -1} {t("billingInfo.days")}
</p>
{parsedData.billingDataMod.amount && parsedData.billingDataMod.amount !== "0" && parsedData.billingDataMod.amount !== "-1" ? (
<p className={cn("text-[10px] text-muted-foreground ")}>
: {parsedData.billingDataMod.amount}/{parsedData.billingDataMod.cycle}
{t("billingInfo.price")}: {parsedData.billingDataMod.amount}/{parsedData.billingDataMod.cycle}
</p>
) : parsedData.billingDataMod.amount === "0" ? (
<p className={cn("text-[10px] text-green-600 ")}></p>
<p className={cn("text-[10px] text-green-600 ")}>{t("billingInfo.free")}</p>
) : parsedData.billingDataMod.amount === "-1" ? (
<p className={cn("text-[10px] text-pink-600 ")}></p>
<p className={cn("text-[10px] text-pink-600 ")}>{t("billingInfo.usage-baseed")}</p>
) : null}
</>
)

View File

@ -105,5 +105,15 @@
"offlineReady": "App ready to work offline",
"newContent": "New content available",
"reload": "Update"
},
"billingInfo": {
"remaining": "Remaining",
"error": "error",
"indefinite": "Indefinite",
"expired": "Expired",
"days": "days",
"price": "Price",
"free": "Free",
"usage-baseed": "Usage-based"
}
}

View File

@ -105,5 +105,15 @@
"offlineReady": "应用可以离线使用了",
"newContent": "发现新版本",
"reload": "更新"
},
"billingInfo": {
"remaining": "剩余天数",
"error": "计算错误",
"indefinite": "永久",
"expired": "已过期",
"days": "天",
"price": "价格",
"free": "免费",
"usage-baseed": "按量计费"
}
}

View File

@ -101,5 +101,15 @@
"status": "狀態",
"avgDelay": "延遲",
"monitorCount": "個監控"
},
"billingInfo": {
"remaining": "剩餘天數",
"error": "獲取失敗",
"indefinite": "無限期",
"expired": "已過期",
"days": "天",
"price": "價格",
"free": "免費",
"usage-baseed": "按量計費"
}
}