feat(i18n): 更新中英文翻译及国际化支持
- 在Workshop和Line模块中添加新的翻译字段 - 修复页面中硬编码的文本,改为使用翻译 - 更新产品线和车间展示的英文翻译内容 - 为卡片组件添加locale属性传递
This commit is contained in:
@@ -4,6 +4,7 @@ import { getWorkShop, getWorkShops } from "@/lib/workshop";
|
||||
import { WorkShop } from "@/types/workShop";
|
||||
import { Metadata } from "next";
|
||||
import { Locale } from "next-intl";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
|
||||
// 固定 Params 类型为普通对象(Next.js 原生传参无异步)
|
||||
type Params = {
|
||||
@@ -45,6 +46,7 @@ export async function generateMetadata({
|
||||
export default async function WorkshopDetailPage({ params }: { params: Params }) {
|
||||
const { locale, slug } = await params;
|
||||
const workShop = await getWorkShop(locale, slug);
|
||||
const t = await getTranslations({ locale, namespace: "Workshop" });
|
||||
|
||||
if (!workShop) return null;
|
||||
|
||||
@@ -78,7 +80,7 @@ export default async function WorkshopDetailPage({ params }: { params: Params })
|
||||
{workShop.images?.length > 0 && (
|
||||
<div className="bg-white rounded-xl p-8 shadow-xl mt-12">
|
||||
<h2 className="text-2xl font-semibold text-gray-800 mb-6 border-b pb-3 border-gray-200">
|
||||
车间图片
|
||||
{t("pageImages")}
|
||||
</h2>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{workShop.images.map((img, index) => {
|
||||
|
||||
@@ -93,7 +93,7 @@ export default async function Page({ params }: { params: Params }) {
|
||||
{workShops.length > 0 ? (
|
||||
workShops.map((workshop) => {
|
||||
const stableKey = `${workshop.title}-${workshop.locale}`;
|
||||
return <WorkshopCard key={stableKey} workshop={workshop} />;
|
||||
return <WorkshopCard key={stableKey} workshop={{ ...workshop, locale }} />;
|
||||
})
|
||||
) : (
|
||||
<EmptyState />
|
||||
|
||||
Reference in New Issue
Block a user