Skip to content

Commit 4aa700f

Browse files
ericyangpanclaude
andcommitted
refactor(product-components): use tComponent + tShared translation pattern
- Update ModelSpecifications component - Update PlatformLinks component - Update ProductHero component - Update ProductPricing component - Update ResourceLinks component - Update VendorMatrix component Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4e06d8e commit 4aa700f

File tree

6 files changed

+23
-20
lines changed

6 files changed

+23
-20
lines changed

src/components/product/ModelSpecifications.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export interface ModelSpecificationsProps {
1313
* context window, max output, and token pricing.
1414
*/
1515
export function ModelSpecifications({ model }: ModelSpecificationsProps) {
16-
const tComponent = useTranslations('components.product.modelSpecifications')
1716
const tShared = useTranslations('shared')
1817
const hasContent =
1918
model.size ||
@@ -31,7 +30,7 @@ export function ModelSpecifications({ model }: ModelSpecificationsProps) {
3130
<section className="py-[var(--spacing-lg)] border-b border-[var(--color-border)]">
3231
<div className="max-w-8xl mx-auto px-[var(--spacing-md)]">
3332
<h2 className="text-2xl font-semibold tracking-[-0.02em] mb-[var(--spacing-sm)]">
34-
{tComponent('title')}
33+
{tShared('labels.specifications')}
3534
</h2>
3635

3736
<div className="grid grid-cols-1 md:grid-cols-2 gap-[var(--spacing-md)] mt-[var(--spacing-lg)]">
@@ -46,7 +45,7 @@ export function ModelSpecifications({ model }: ModelSpecificationsProps) {
4645

4746
<div className="border border-[var(--color-border)] p-[var(--spacing-md)]">
4847
<h3 className="text-xs text-[var(--color-text-muted)] uppercase tracking-wider font-medium mb-[var(--spacing-xs)]">
49-
{tComponent('contextWindow')}
48+
{tShared('labels.totalContext')}
5049
</h3>
5150
<p className="text-lg font-semibold tracking-tight">
5251
{formatTokenCount(model.contextWindow)}
@@ -71,7 +70,7 @@ export function ModelSpecifications({ model }: ModelSpecificationsProps) {
7170
{model.tokenPricing.input !== null && model.tokenPricing.input !== undefined && (
7271
<p className="text-sm">
7372
<span className="text-[var(--color-text-muted)] text-xs">
74-
{tComponent('input')}{' '}
73+
{tShared('labels.input')}{' '}
7574
</span>
7675
<span className="font-semibold tracking-tight">
7776
${model.tokenPricing.input}/M
@@ -81,7 +80,7 @@ export function ModelSpecifications({ model }: ModelSpecificationsProps) {
8180
{model.tokenPricing.output !== null && model.tokenPricing.output !== undefined && (
8281
<p className="text-sm">
8382
<span className="text-[var(--color-text-muted)] text-xs">
84-
{tComponent('output')}{' '}
83+
{tShared('labels.output')}{' '}
8584
</span>
8685
<span className="font-semibold tracking-tight">
8786
${model.tokenPricing.output}/M
@@ -91,7 +90,7 @@ export function ModelSpecifications({ model }: ModelSpecificationsProps) {
9190
{model.tokenPricing.cache !== null && model.tokenPricing.cache !== undefined && (
9291
<p className="text-sm">
9392
<span className="text-[var(--color-text-muted)] text-xs">
94-
{tComponent('cache')}{' '}
93+
{tShared('labels.cache')}{' '}
9594
</span>
9695
<span className="font-semibold tracking-tight">
9796
${model.tokenPricing.cache}/M

src/components/product/PlatformLinks.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export function PlatformLinks({
2121
gridCols = 'grid-cols-1 md:grid-cols-3',
2222
}: PlatformLinksProps) {
2323
const tComponent = useTranslations('components.product.platformLinks')
24+
const tShared = useTranslations('shared')
2425

2526
if (!platformUrls) {
2627
return null
@@ -29,24 +30,24 @@ export function PlatformLinks({
2930
const links = [
3031
{
3132
key: 'huggingface',
32-
title: tComponent('aiPlatforms.huggingface.title'),
33+
title: tShared('platforms.huggingface'),
3334
description: tComponent('aiPlatforms.huggingface.description'),
3435
},
3536
{
3637
key: 'artificialAnalysis',
37-
title: tComponent('aiPlatforms.artificialAnalysis.title'),
38+
title: tShared('platforms.artificialAnalysis'),
3839
description: tComponent('aiPlatforms.artificialAnalysis.description'),
3940
},
4041
{
4142
key: 'openrouter',
42-
title: tComponent('aiPlatforms.openrouter.title'),
43+
title: tShared('platforms.openrouter'),
4344
description: tComponent('aiPlatforms.openrouter.description'),
4445
},
4546
] as const
4647

4748
return (
4849
<LinkCardGrid
49-
title={tComponent('title')}
50+
title={tShared('labels.findOnAiPlatforms')}
5051
links={links}
5152
urls={platformUrls}
5253
layout={layout}

src/components/product/ProductHero.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ export function ProductHero({
116116
<div className="inline-flex items-center gap-[var(--spacing-sm)] flex-wrap px-[var(--spacing-md)] py-[var(--spacing-md)] border border-[var(--color-border)] text-sm">
117117
{vendor && (
118118
<div className="flex gap-1">
119-
<span className="text-[var(--color-text-muted)]">{tShared('terms.vendor')}:</span>
119+
<span className="text-[var(--color-text-muted)]">
120+
{tShared('categories.singular.vendor')}:
121+
</span>
120122
<span className="font-medium">{vendor}</span>
121123
</div>
122124
)}

src/components/product/ProductPricing.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export interface ProductPricingProps {
77
}
88

99
export function ProductPricing({ pricing, pricingUrl }: ProductPricingProps) {
10-
const tComponent = useTranslations('components.product.productPricing')
1110
const tShared = useTranslations('shared')
1211

1312
if (!pricing || pricing.length === 0) {
@@ -50,7 +49,7 @@ export function ProductPricing({ pricing, pricingUrl }: ProductPricingProps) {
5049
rel="noopener"
5150
className="inline-flex items-center gap-[var(--spacing-xs)] text-sm text-[var(--color-text-secondary)] hover:text-[var(--color-text)] transition-colors"
5251
>
53-
{tComponent('viewFullDetails')}
52+
{tShared('actions.viewFullDetails')}
5453
</a>
5554
</div>
5655
)}

src/components/product/ResourceLinks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function ResourceLinks({
5454

5555
return (
5656
<LinkCardGrid
57-
title={tComponent('resources')}
57+
title={tShared('terms.resources')}
5858
links={links}
5959
urls={resourceUrls}
6060
layout={layout}

src/components/product/VendorMatrix.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ interface MatrixCellProps {
2020
* Gets the localized label for a product category, with simple plural handling.
2121
*/
2222
function getCategoryLabel(
23-
t: ReturnType<typeof useTranslations>,
23+
tShared: ReturnType<typeof useTranslations>,
2424
category: ProductCategory,
2525
count: number
2626
): string {
2727
if (count === 1) {
28-
return t(`categories.${category}`)
28+
return tShared(`categories.${category}`)
2929
}
30-
return t(`categoriesPlural.${category}`)
30+
return tShared(`categories.plural.${category}`)
3131
}
3232

3333
/**
@@ -45,6 +45,7 @@ function getVendorTypeLabel(t: ReturnType<typeof useTranslations>, type: string)
4545
function MatrixCell({ products, category }: MatrixCellProps) {
4646
const [isExpanded, setIsExpanded] = useState(false)
4747
const tComponent = useTranslations('components.product.vendorMatrix')
48+
const tShared = useTranslations('shared')
4849

4950
if (products.length === 0) {
5051
return (
@@ -104,7 +105,7 @@ function MatrixCell({ products, category }: MatrixCellProps) {
104105
<span className="font-medium text-sm tracking-tight">
105106
{tComponent('cell.summary', {
106107
count: products.length,
107-
category: getCategoryLabel(tComponent, category, products.length),
108+
category: getCategoryLabel(tShared, category, products.length),
108109
})}
109110
</span>
110111
<span className="text-xs text-[var(--color-text-muted)]">
@@ -143,6 +144,7 @@ export default function VendorMatrix({ matrixData }: VendorMatrixProps) {
143144
const [selectedVendorTypes, setSelectedVendorTypes] = useState<Set<string>>(new Set())
144145
const [sortBy, setSortBy] = useState<'name' | 'products'>('products')
145146
const tComponent = useTranslations('components.product.vendorMatrix')
147+
const tShared = useTranslations('shared')
146148

147149
const filteredAndSortedData = useMemo(() => {
148150
let filtered = matrixData
@@ -306,7 +308,7 @@ export default function VendorMatrix({ matrixData }: VendorMatrixProps) {
306308
: 'border-[var(--color-border)] hover:bg-[var(--color-hover)]'
307309
}`}
308310
>
309-
{tComponent('controls.sortProducts')}
311+
{tShared('terms.products')}
310312
</button>
311313
</div>
312314
</div>
@@ -322,7 +324,7 @@ export default function VendorMatrix({ matrixData }: VendorMatrixProps) {
322324
</div>
323325
{PRODUCT_CATEGORIES.map(cat => (
324326
<div key={cat} className="font-medium text-sm text-center px-2">
325-
{tComponent(`categories.${cat}`)}
327+
{tShared(`categories.singular.${cat}`)}
326328
</div>
327329
))}
328330
</div>

0 commit comments

Comments
 (0)