Skip to content

Commit cd44815

Browse files
committed
Translate search button on NotFound page
1 parent a19b3ba commit cd44815

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

.changeset/sour-ducks-hug.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@bigcommerce/catalyst-core": patch
3+
---
4+
5+
Add translations for 'Search' button on 404 page
6+
7+
## Migration
8+
9+
1. Add `"search"` translation key in the `"NotFound"` translations
10+
2. In `core/vibes/soul/sections/not-found/index.tsx`, add a `ctaLabel` property and ensure it is used in place of the "Search" text
11+
3. In `core/app/[locale]/not-found.tsx`, pass the `ctaLabel` prop as the new translation key `ctaLabel={t('search')}`

core/app/[locale]/not-found.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default async function NotFound() {
1313

1414
<NotFoundSection
1515
className="flex-1 place-content-center"
16+
ctaLabel={t('search')}
1617
subtitle={t('subtitle')}
1718
title={t('title')}
1819
/>

core/messages/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@
423423
"NotFound": {
424424
"title": "We couldn't find that page!",
425425
"subtitle": "Try searching for something else or go back to the home page.",
426-
"featuredProducts": "Featured products"
426+
"featuredProducts": "Featured products",
427+
"search": "Search"
427428
},
428429
"Components": {
429430
"Header": {

core/vibes/soul/sections/not-found/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useSearch } from '~/context/search-context';
77
export interface NotFoundProps {
88
title?: string;
99
subtitle?: string;
10+
ctaLabel?: string;
1011
className?: string;
1112
}
1213

@@ -27,6 +28,7 @@ export interface NotFoundProps {
2728
export function NotFound({
2829
title = 'Not found',
2930
subtitle = "Take a look around if you're lost.",
31+
ctaLabel = 'Search',
3032
className = '',
3133
}: NotFoundProps) {
3234
const { setIsSearchOpen } = useSearch();
@@ -44,7 +46,7 @@ export function NotFound({
4446
<p className="mb-4 text-lg text-[var(--not-found-subtitle,hsl(var(--contrast-500)))]">
4547
{subtitle}
4648
</p>
47-
<Button onClick={handleOpenSearch}>Search</Button>
49+
<Button onClick={handleOpenSearch}>{ctaLabel}</Button>
4850
</header>
4951
</SectionLayout>
5052
);

0 commit comments

Comments
 (0)