Skip to content

Commit 402ac54

Browse files
ericyangpanclaude
andcommitted
refactor(i18n): update component code to use tComponent + tShared pattern
Update all page and component files to follow the new i18n architecture: - Import and use tShared for common/shared translations - Simplify translation namespace patterns - Remove hard-coded namespace assumptions in menu configs Affected areas: - Product detail pages (clis, extensions, ides, models, model-providers, vendors) - Comparison pages - Homepage - Components (Header, FilterSortBar, Navigation, Product, Sidebar) - Metadata generators Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f3e5539 commit 402ac54

File tree

32 files changed

+174
-149
lines changed

32 files changed

+174
-149
lines changed

src/app/[locale]/clis/[slug]/page.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export default async function CLIPage({
6868
notFound()
6969
}
7070

71-
const tPage = await getTranslations({ locale, namespace: 'pages.cliDetail' })
7271
const tShared = await getTranslations({ locale, namespace: 'shared' })
7372

7473
// Transform URLs for component props
@@ -114,7 +113,7 @@ export default async function CLIPage({
114113
description={cli.description}
115114
vendor={cli.vendor}
116115
category="CLI"
117-
categoryLabel={tPage('categoryLabel')}
116+
categoryLabel={tShared('categories.singular.cli')}
118117
verified={cli.verified ?? false}
119118
latestVersion={cli.latestVersion}
120119
license={cli.license}
@@ -135,7 +134,7 @@ export default async function CLIPage({
135134

136135
<ProductCommands install={cli.installCommand} launch={cli.launchCommand} />
137136

138-
<BackToNavigation href="/clis" title={tPage('allCLIs')} />
137+
<BackToNavigation href="/clis" title={tShared('categories.all.clis')} />
139138
</main>
140139
</PageLayout>
141140
)

src/app/[locale]/clis/comparison/page.client.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ export default function CLIComparisonPageClient({ locale: _locale }: Props) {
2424
const columns: ComparisonColumn[] = [
2525
{
2626
key: 'vendor',
27-
label: tPage('columns.vendor'),
27+
label: tShared('terms.vendor'),
2828
},
2929
{
3030
key: 'license',
31-
label: tPage('columns.license'),
31+
label: tShared('terms.license'),
3232
render: (value: unknown, item: Record<string, unknown>) =>
3333
renderLicense(value, item, tShared),
3434
},
3535
{
3636
key: 'latestVersion',
37-
label: tPage('columns.version'),
37+
label: tShared('terms.version'),
3838
},
3939
{
4040
key: 'platforms',
41-
label: tPage('columns.platforms'),
41+
label: tShared('terms.platforms'),
4242
render: (value: unknown) => {
4343
const platforms = value as Array<{ os: string }> | string[]
4444
if (!platforms || platforms.length === 0) return '-'
@@ -71,7 +71,7 @@ export default function CLIComparisonPageClient({ locale: _locale }: Props) {
7171
},
7272
{
7373
key: 'githubStars',
74-
label: tPage('columns.githubStars'),
74+
label: tShared('terms.stars'),
7575
render: (_: unknown, item: Record<string, unknown>) => {
7676
const id = item.id as string
7777
const stars = getGithubStars('clis', id)
@@ -132,7 +132,7 @@ export default function CLIComparisonPageClient({ locale: _locale }: Props) {
132132
target="_blank"
133133
rel="noopener"
134134
className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] transition-colors"
135-
title={tPage('linkTitles.officialWebsite')}
135+
title={tShared('terms.visitWebsite')}
136136
>
137137
<Home className="w-3.5 h-3.5" />
138138
</a>
@@ -147,7 +147,7 @@ export default function CLIComparisonPageClient({ locale: _locale }: Props) {
147147
target="_blank"
148148
rel="noopener"
149149
className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] transition-colors"
150-
title={tPage('linkTitles.download')}
150+
title={tShared('actions.download')}
151151
>
152152
<Download className="w-3.5 h-3.5" />
153153
</a>
@@ -162,7 +162,7 @@ export default function CLIComparisonPageClient({ locale: _locale }: Props) {
162162
target="_blank"
163163
rel="noopener"
164164
className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] transition-colors"
165-
title={tPage('linkTitles.documentation')}
165+
title={tShared('terms.documentation')}
166166
>
167167
<FileText className="w-3.5 h-3.5" />
168168
</a>
@@ -304,6 +304,7 @@ export default function CLIComparisonPageClient({ locale: _locale }: Props) {
304304
items={clis as unknown as Record<string, unknown>[]}
305305
columns={columns}
306306
itemLinkPrefix={`/clis`}
307+
nameColumnLabel={tPage('columns.name')}
307308
/>
308309
</div>
309310
</section>

src/app/[locale]/clis/page.client.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export default function CLIsPageClient({ locale }: Props) {
108108
href="/clis/comparison"
109109
className="text-sm px-[var(--spacing-md)] py-[var(--spacing-xs)] border border-[var(--color-border)] hover:border-[var(--color-border-strong)] transition-colors"
110110
>
111-
{tPage('compareAll')}
111+
{tShared('actions.compareAll')}
112112
</Link>
113113
}
114114
/>

src/app/[locale]/extensions/[slug]/page.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ export default async function ExtensionPage({
7272
notFound()
7373
}
7474

75-
const tPage = await getTranslations({ locale, namespace: 'pages.extensionDetail' })
7675
const tShared = await getTranslations({ locale, namespace: 'shared' })
7776

7877
// Transform URLs for component props
@@ -111,7 +110,7 @@ export default async function ExtensionPage({
111110
extension.supportedIdes && extension.supportedIdes.length > 0
112111
? [
113112
{
114-
label: tPage('supportedIdes') || 'Supported IDEs',
113+
label: tShared('terms.supportedIdes'),
115114
value: extension.supportedIdes.map(ide => ide.ideId).join(', '),
116115
},
117116
]
@@ -133,8 +132,8 @@ export default async function ExtensionPage({
133132
name={extension.name}
134133
description={extension.description}
135134
vendor={extension.vendor}
136-
category="IDE"
137-
categoryLabel={tPage('categoryLabel')}
135+
category="EXTENSION"
136+
categoryLabel={tShared('categories.singular.extension')}
138137
verified={extension.verified ?? false}
139138
latestVersion={extension.latestVersion}
140139
license={extension.license}
@@ -153,7 +152,7 @@ export default async function ExtensionPage({
153152

154153
<CommunityLinks communityUrls={extension.communityUrls} />
155154

156-
<BackToNavigation href="/extensions" title={tPage('allExtensions')} />
155+
<BackToNavigation href="/extensions" title={tShared('categories.all.extensions')} />
157156
</main>
158157
</PageLayout>
159158
)

src/app/[locale]/extensions/comparison/page.client.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ export default function ExtensionComparisonPageClient({ locale: _locale }: Props
2323
const columns: ComparisonColumn[] = [
2424
{
2525
key: 'vendor',
26-
label: tPage('columns.vendor'),
26+
label: tShared('terms.vendor'),
2727
},
2828
{
2929
key: 'license',
30-
label: tPage('columns.license'),
30+
label: tShared('terms.license'),
3131
render: (value: unknown, item: Record<string, unknown>) =>
3232
renderLicense(value, item, tShared),
3333
},
3434
{
3535
key: 'latestVersion',
36-
label: tPage('columns.version'),
36+
label: tShared('terms.version'),
3737
},
3838
{
3939
key: 'supportedIdes',
40-
label: tPage('columns.supportedIdes'),
40+
label: tShared('terms.supportedIdes'),
4141
render: (value: unknown) => {
4242
const supportedIdes = value as Array<{ ideId: string }> | undefined
4343
if (!supportedIdes || supportedIdes.length === 0) return '-'
@@ -57,7 +57,7 @@ export default function ExtensionComparisonPageClient({ locale: _locale }: Props
5757
},
5858
{
5959
key: 'githubStars',
60-
label: tPage('columns.githubStars'),
60+
label: tShared('terms.stars'),
6161
render: (_: unknown, item: Record<string, unknown>) => {
6262
const id = item.id as string
6363
const stars = getGithubStars('extensions', id)
@@ -118,7 +118,7 @@ export default function ExtensionComparisonPageClient({ locale: _locale }: Props
118118
target="_blank"
119119
rel="noopener"
120120
className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] transition-colors"
121-
title={tPage('linkTitles.officialWebsite')}
121+
title={tShared('terms.visitWebsite')}
122122
>
123123
<Home className="w-3.5 h-3.5" />
124124
</a>
@@ -133,7 +133,7 @@ export default function ExtensionComparisonPageClient({ locale: _locale }: Props
133133
target="_blank"
134134
rel="noopener"
135135
className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] transition-colors"
136-
title={tPage('linkTitles.download')}
136+
title={tShared('actions.download')}
137137
>
138138
<Download className="w-3.5 h-3.5" />
139139
</a>
@@ -148,7 +148,7 @@ export default function ExtensionComparisonPageClient({ locale: _locale }: Props
148148
target="_blank"
149149
rel="noopener"
150150
className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] transition-colors"
151-
title={tPage('linkTitles.documentation')}
151+
title={tShared('terms.documentation')}
152152
>
153153
<FileText className="w-3.5 h-3.5" />
154154
</a>
@@ -290,6 +290,7 @@ export default function ExtensionComparisonPageClient({ locale: _locale }: Props
290290
items={extensions as unknown as Record<string, unknown>[]}
291291
columns={columns}
292292
itemLinkPrefix={`/extensions`}
293+
nameColumnLabel={tPage('columns.name')}
293294
/>
294295
</div>
295296
</section>

src/app/[locale]/extensions/page.client.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export default function ExtensionsPageClient({ locale }: Props) {
111111
href="/extensions/comparison"
112112
className="text-sm px-[var(--spacing-md)] py-[var(--spacing-xs)] border border-[var(--color-border)] hover:border-[var(--color-border-strong)] transition-colors"
113113
>
114-
{tPage('compareAll')}
114+
{tShared('actions.compareAll')}
115115
</Link>
116116
}
117117
/>

src/app/[locale]/ides/[slug]/page.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export default async function IDEPage({
6868
notFound()
6969
}
7070

71-
const tPage = await getTranslations({ locale, namespace: 'pages.ideDetail' })
7271
const tShared = await getTranslations({ locale, namespace: 'shared' })
7372

7473
// Transform URLs for component props
@@ -114,7 +113,7 @@ export default async function IDEPage({
114113
description={ide.description}
115114
vendor={ide.vendor}
116115
category="IDE"
117-
categoryLabel={tPage('categoryLabel')}
116+
categoryLabel={tShared('categories.singular.ide')}
118117
verified={ide.verified ?? false}
119118
latestVersion={ide.latestVersion}
120119
license={ide.license}
@@ -135,7 +134,7 @@ export default async function IDEPage({
135134

136135
<ProductCommands install={ide.installCommand} launch={ide.launchCommand} />
137136

138-
<BackToNavigation href="/ides" title={tPage('allIDEs')} />
137+
<BackToNavigation href="/ides" title={tShared('categories.all.ides')} />
139138
</main>
140139
</PageLayout>
141140
)

src/app/[locale]/ides/comparison/page.client.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ export default function IDEComparisonPageClient({ locale: _locale }: Props) {
2424
const columns: ComparisonColumn[] = [
2525
{
2626
key: 'vendor',
27-
label: tPage('columns.vendor'),
27+
label: tShared('terms.vendor'),
2828
},
2929
{
3030
key: 'license',
31-
label: tPage('columns.license'),
31+
label: tShared('terms.license'),
3232
render: (value: unknown, item: Record<string, unknown>) =>
3333
renderLicense(value, item, tShared),
3434
},
3535
{
3636
key: 'latestVersion',
37-
label: tPage('columns.version'),
37+
label: tShared('terms.version'),
3838
},
3939
{
4040
key: 'platforms',
41-
label: tPage('columns.platforms'),
41+
label: tShared('terms.platforms'),
4242
render: (value: unknown) => {
4343
const platforms = value as Array<{ os: string }> | string[]
4444
if (!platforms || platforms.length === 0) return '-'
@@ -71,7 +71,7 @@ export default function IDEComparisonPageClient({ locale: _locale }: Props) {
7171
},
7272
{
7373
key: 'githubStars',
74-
label: tPage('columns.githubStars'),
74+
label: tShared('terms.stars'),
7575
render: (_: unknown, item: Record<string, unknown>) => {
7676
const id = item.id as string
7777
const stars = getGithubStars('ides', id)
@@ -132,7 +132,7 @@ export default function IDEComparisonPageClient({ locale: _locale }: Props) {
132132
target="_blank"
133133
rel="noopener"
134134
className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] transition-colors"
135-
title={tPage('linkTitles.officialWebsite')}
135+
title={tShared('terms.visitWebsite')}
136136
>
137137
<Home className="w-3.5 h-3.5" />
138138
</a>
@@ -147,7 +147,7 @@ export default function IDEComparisonPageClient({ locale: _locale }: Props) {
147147
target="_blank"
148148
rel="noopener"
149149
className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] transition-colors"
150-
title={tPage('linkTitles.download')}
150+
title={tShared('actions.download')}
151151
>
152152
<Download className="w-3.5 h-3.5" />
153153
</a>
@@ -162,7 +162,7 @@ export default function IDEComparisonPageClient({ locale: _locale }: Props) {
162162
target="_blank"
163163
rel="noopener"
164164
className="text-[var(--color-text)] hover:text-[var(--color-text-secondary)] transition-colors"
165-
title={tPage('linkTitles.documentation')}
165+
title={tShared('terms.documentation')}
166166
>
167167
<FileText className="w-3.5 h-3.5" />
168168
</a>
@@ -304,6 +304,7 @@ export default function IDEComparisonPageClient({ locale: _locale }: Props) {
304304
items={ides as unknown as Record<string, unknown>[]}
305305
columns={columns}
306306
itemLinkPrefix={`/ides`}
307+
nameColumnLabel={tPage('columns.name')}
307308
/>
308309
</div>
309310
</section>

src/app/[locale]/ides/page.client.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export default function IDEsPageClient({ locale }: Props) {
108108
href="/ides/comparison"
109109
className="text-sm px-[var(--spacing-md)] py-[var(--spacing-xs)] border border-[var(--color-border)] hover:border-[var(--color-border-strong)] transition-colors"
110110
>
111-
{tPage('compareAll')}
111+
{tShared('actions.compareAll')}
112112
</Link>
113113
}
114114
/>

src/app/[locale]/model-providers/[slug]/page.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export default async function ProviderPage({
5757
notFound()
5858
}
5959

60-
const tPage = await getTranslations({ locale, namespace: 'pages.modelProviderDetail' })
6160
const tShared = await getTranslations({ locale, namespace: 'shared' })
6261

6362
// Generate JSON-LD schema
@@ -86,10 +85,10 @@ export default async function ProviderPage({
8685
name={provider.name}
8786
description={provider.description}
8887
category="PROVIDER"
89-
categoryLabel={tPage('categoryLabel')}
88+
categoryLabel={tShared('categories.singular.modelProvider')}
9089
verified={provider.verified ?? false}
9190
type={provider.type}
92-
typeValue={provider.type ? tPage(`providerTypes.${provider.type}`) : undefined}
91+
typeValue={provider.type ? tShared(`providerTypes.${provider.type}`) : undefined}
9392
websiteUrl={provider.websiteUrl}
9493
docsUrl={provider.docsUrl ?? null}
9594
applyKeyUrl={provider.applyKeyUrl}
@@ -99,7 +98,10 @@ export default async function ProviderPage({
9998

10099
<CommunityLinks communityUrls={provider.communityUrls} />
101100

102-
<BackToNavigation href="/model-providers" title={tPage('allModelProviders')} />
101+
<BackToNavigation
102+
href="/model-providers"
103+
title={tShared('categories.all.modelProviders')}
104+
/>
103105
</main>
104106
</PageLayout>
105107
)

0 commit comments

Comments
 (0)