Skip to content

Commit

Permalink
fix: public note i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
hamster1963 committed Dec 21, 2024
1 parent a8c7253 commit c600b81
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/components/billingInfo.tsx
Original file line number Diff line number Diff line change
@@ -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
}
Expand All @@ -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}
</>
)
Expand Down
10 changes: 10 additions & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
10 changes: 10 additions & 0 deletions src/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,15 @@
"offlineReady": "应用可以离线使用了",
"newContent": "发现新版本",
"reload": "更新"
},
"billingInfo": {
"remaining": "剩余天数",
"error": "计算错误",
"indefinite": "永久",
"expired": "已过期",
"days": "",
"price": "价格",
"free": "免费",
"usage-baseed": "按量计费"
}
}
10 changes: 10 additions & 0 deletions src/locales/zh-TW/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,15 @@
"status": "狀態",
"avgDelay": "延遲",
"monitorCount": "個監控"
},
"billingInfo": {
"remaining": "剩餘天數",
"error": "獲取失敗",
"indefinite": "無限期",
"expired": "已過期",
"days": "",
"price": "價格",
"free": "免費",
"usage-baseed": "按量計費"
}
}

0 comments on commit c600b81

Please sign in to comment.