'多语言'

This commit is contained in:
eric
2026-03-08 04:30:57 -05:00
parent 51eeea3be3
commit def36bf3aa
30 changed files with 6058 additions and 323 deletions

View File

@@ -1,3 +1,6 @@
"use client";
import { useTranslation } from "@/i18n/navigation";
import toolsData from "../data/tools.json";
const categories = toolsData.categories as Array<{
@@ -14,29 +17,27 @@ function truncateDesc(desc: string, maxLen = 5) {
return desc.slice(0, maxLen) + "...";
}
const toolStats = (() => {
const total = categories.reduce((s, c) => s + c.tools.length, 0);
return [
{ value: `${total}+`, label: "精选工具" },
{ value: String(categories.length), label: "分类" },
{ value: "数字游民", label: "出海" },
{ value: "佣金", label: "推荐" },
];
})();
export default function Tools() {
const { t } = useTranslation("tools");
const total = categories.reduce((s, c) => s + c.tools.length, 0);
const toolStats = [
{ value: `${total}+`, key: "tools" as const },
{ value: String(categories.length), key: "categories" as const },
{ value: "数字游民", key: "nomad" as const },
{ value: "佣金", key: "affiliate" as const },
];
return (
<section id="tools" className="py-20 sm:py-28">
<div className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
<div className="text-center">
<div className="mb-4 inline-flex items-center gap-2 rounded-full border border-sky-200 bg-sky-50 px-4 py-1.5 text-sm font-medium text-sky-700">
🚀 50+
{t("badge")}
</div>
<h2 className="text-3xl font-bold tracking-tight sm:text-4xl">
<span className="gradient-text"></span>
<span className="gradient-text">{t("title")}</span>
</h2>
<p className="mx-auto mt-4 max-w-2xl text-lg text-slate-600">
VPS
{t("subtitle")}
</p>
</div>
@@ -83,17 +84,16 @@ export default function Tools() {
))}
</div>
{/* Stats bar */}
<div className="mt-14 grid grid-cols-2 gap-4 sm:grid-cols-4">
{toolStats.map((s) => (
<div
key={s.label}
key={s.key}
className="rounded-2xl border border-slate-100 bg-white p-5 text-center shadow-sm"
>
<div className="text-3xl font-extrabold text-sky-600">
{s.value}
</div>
<div className="mt-1 text-sm text-slate-500">{s.label}</div>
<div className="mt-1 text-sm text-slate-500">{t(`stats.${s.key}`)}</div>
</div>
))}
</div>