diff --git a/src/app/[locale]/keyword-cloud/components/CloudWord.tsx b/src/app/[locale]/keyword-cloud/components/CloudWord.tsx index 57a1bdd..4b9b5db 100644 --- a/src/app/[locale]/keyword-cloud/components/CloudWord.tsx +++ b/src/app/[locale]/keyword-cloud/components/CloudWord.tsx @@ -15,12 +15,15 @@ export interface KeywordData { word: string; trendScore: number; description: string; + descriptionEn?: string | null; detailPoints: string[]; + detailPointsEn?: string[] | null; visualConfig: VisualConfig; } interface CloudWordProps { data: KeywordData; + locale: string; } // 颜色映射 @@ -31,11 +34,15 @@ const colorMap: Record = { gray: 'bg-gray-100 dark:bg-gray-700', }; -export function CloudWord({ data }: CloudWordProps) { - const { word, visualConfig, description, detailPoints } = data; +export function CloudWord({ data, locale }: CloudWordProps) { + const { word, visualConfig, description, descriptionEn, detailPoints, detailPointsEn } = data; const { color, size, border, rotation } = visualConfig; const colorClass = colorMap[color]; + // 根据语言选择内容 + const displayDescription = locale === 'en' && descriptionEn ? descriptionEn : description; + const displayPoints = locale === 'en' && detailPointsEn ? detailPointsEn : detailPoints; + return ( diff --git a/src/app/[locale]/keyword-cloud/components/KeywordCloud.tsx b/src/app/[locale]/keyword-cloud/components/KeywordCloud.tsx index d1f9b1d..18c60e1 100644 --- a/src/app/[locale]/keyword-cloud/components/KeywordCloud.tsx +++ b/src/app/[locale]/keyword-cloud/components/KeywordCloud.tsx @@ -6,7 +6,18 @@ import { QuarterNavigator } from './QuarterNavigator'; import { ProgressIndicator } from './ProgressIndicator'; import { useKeywordCloud } from '@/hooks/useKeywordCloudClient'; -export function KeywordCloud({ initialQuarter }: { initialQuarter: string }) { +interface KeywordCloudProps { + initialQuarter: string; + locale: string; + texts: { + loading: string; + loadFailed: string; + retry: string; + hotKeyword: string; + }; +} + +export function KeywordCloud({ initialQuarter, locale, texts }: KeywordCloudProps) { const [currentQuarter, setCurrentQuarter] = useState(initialQuarter); const [quarters, setQuarters] = useState([]); const { data, isLoading, error } = useKeywordCloud(currentQuarter); @@ -41,7 +52,7 @@ export function KeywordCloud({ initialQuarter }: { initialQuarter: string }) {
-

加载中...

+

{texts.loading}

); @@ -52,13 +63,13 @@ export function KeywordCloud({ initialQuarter }: { initialQuarter: string }) {

- 加载失败 + {texts.loadFailed}

@@ -87,7 +98,7 @@ export function KeywordCloud({ initialQuarter }: { initialQuarter: string }) {
{data.keywords.map((keyword) => ( - + ))}
@@ -95,7 +106,7 @@ export function KeywordCloud({ initialQuarter }: { initialQuarter: string }) { {/* 装饰元素 */} {data.keywords.length > 0 && firstKeyword && (
- “{firstKeyword.word}” 是本季度最热门词汇! + {texts.hotKeyword.replace('{word}', firstKeyword.word)}
)} diff --git a/src/app/[locale]/keyword-cloud/page.tsx b/src/app/[locale]/keyword-cloud/page.tsx index 40ad80b..3d59a6f 100644 --- a/src/app/[locale]/keyword-cloud/page.tsx +++ b/src/app/[locale]/keyword-cloud/page.tsx @@ -1,4 +1,5 @@ import { KeywordCloud } from './components/KeywordCloud'; +import { getTranslations } from 'next-intl/server'; interface PageProps { params: { @@ -9,27 +10,51 @@ interface PageProps { }; } -export default function KeywordCloudPage({ searchParams }: PageProps) { +export async function generateMetadata({ + params +}: { + params: Promise<{ locale: string }> +}) { + const { locale } = await params; + const t = await getTranslations('keywordCloud'); + + return { + title: t('metaTitle'), + description: t('metaDescription'), + }; +} + +export default async function KeywordCloudPage({ searchParams, params }: PageProps) { + const { locale } = await params; + const t = await getTranslations('keywordCloud'); + // 如果 URL 中有 quarter 参数,使用它;否则使用默认季度 const quarter = searchParams.quarter || '2024-Q1'; + const texts = { + loading: t('loading'), + loadFailed: t('loadFailed'), + retry: t('retry'), + hotKeyword: t('hotKeyword'), + }; + return (
{/* 页面标题 */}
- AI 热点追踪 + {t('badge')}

- 季度 AI 热点词云 + {t('title')} {t('titleHighlight')}

- 从 “大型语言模型” 到 “Agent 工作流”。探索 AI 话语的演变历程。 + {t('subtitle')}

{/* 词云组件 */} - +
); } diff --git a/src/messages/en.json b/src/messages/en.json index c0a9af5..8b5d8ac 100644 --- a/src/messages/en.json +++ b/src/messages/en.json @@ -95,5 +95,17 @@ "followUs": "Follow Us", "copyright": "© 2025 Agent Park. All rights reserved.", "designedFor": "DESIGNED FOR AI BUILDERS" + }, + "keywordCloud": { + "metaTitle": "AI Hotspot Word Cloud - Agent Park", + "metaDescription": "Explore the evolution of quarterly AI hotspots, from Large Language Models to Agent Workflows", + "badge": "AI Trend Tracker", + "title": "Quarterly AI", + "titleHighlight": "Hotspot Word Cloud", + "subtitle": "From “Large Language Models” to “Agent Workflows”. Explore the evolution of AI discourse.", + "loading": "Loading...", + "loadFailed": "Failed to load", + "retry": "Retry", + "hotKeyword": "“{word}” is the hottest keyword this quarter!" } } diff --git a/src/messages/zh.json b/src/messages/zh.json index 6aabbcf..9a92965 100644 --- a/src/messages/zh.json +++ b/src/messages/zh.json @@ -95,5 +95,17 @@ "followUs": "关注我们", "copyright": "© 2025 Agent Park. 保留所有权利。", "designedFor": "专为 AI 构建者设计" + }, + "keywordCloud": { + "metaTitle": "AI 热点词云 - Agent Park", + "metaDescription": "探索季度 AI 热点词汇的演变历程,从大型语言模型到 Agent 工作流", + "badge": "AI 热点追踪", + "title": "季度 AI", + "titleHighlight": "热点词云", + "subtitle": "从 “大型语言模型” 到 “Agent 工作流”。探索 AI 话语的演变历程。", + "loading": "加载中...", + "loadFailed": "加载失败", + "retry": "重试", + "hotKeyword": "“{word}” 是本季度最热门词汇!" } }