From 826f8551774711ecd035e60da79e3c7d156c4e1b Mon Sep 17 00:00:00 2001 From: Jorge Moya Date: Wed, 28 Aug 2024 10:23:48 -0500 Subject: [PATCH 01/30] refactor: home --- core/app/[locale]/(default)/page.tsx | 30 ++++++++++++---------------- core/messages/en.json | 10 ---------- docs/localization.md | 2 -- 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/core/app/[locale]/(default)/page.tsx b/core/app/[locale]/(default)/page.tsx index cb59993fa..012c5297c 100644 --- a/core/app/[locale]/(default)/page.tsx +++ b/core/app/[locale]/(default)/page.tsx @@ -1,6 +1,5 @@ import { removeEdgesAndNodes } from '@bigcommerce/catalyst-client'; -import { NextIntlClientProvider } from 'next-intl'; -import { getMessages, getTranslations, unstable_setRequestLocale } from 'next-intl/server'; +import { getTranslations, unstable_setRequestLocale } from 'next-intl/server'; import { getSessionCustomerId } from '~/auth'; import { client } from '~/client'; @@ -47,7 +46,6 @@ export default async function Home({ params: { locale } }: Props) { const customerId = await getSessionCustomerId(); const t = await getTranslations({ locale, namespace: 'Home' }); - const messages = await getMessages({ locale }); const { data } = await client.fetch({ document: HomePageQuery, @@ -63,20 +61,18 @@ export default async function Home({ params: { locale } }: Props) {
- - - - + +
); diff --git a/core/messages/en.json b/core/messages/en.json index 0384f335d..75def9ed0 100644 --- a/core/messages/en.json +++ b/core/messages/en.json @@ -1,16 +1,6 @@ { - "RootLayout": { - "Metadata": { - "title": "Catalyst Store", - "description": "Example store built with Catalyst", - "other": { - "platform": "bigcommerce.catalyst" - } - } - }, "Home": { "Carousel": { - "bestSellingProducts": "Best Selling Products", "featuredProducts": "Featured Products", "newestProducts": "Newest products" } diff --git a/docs/localization.md b/docs/localization.md index a33e2b6b7..56aa99bf7 100644 --- a/docs/localization.md +++ b/docs/localization.md @@ -51,7 +51,6 @@ For example, the `en.json` file contains the following translation keys: ```json "Home": { "Carousel": { - "bestSellingProducts": "Best Selling Products", "featuredProducts": "Featured Products", "newestProducts": "Newest products" } @@ -63,7 +62,6 @@ In your newly-created JSON file, add a translation of the value to the new local ```json "Home": { "Carousel": { - "bestSellingProducts": "Produits les plus vendus", "featuredProducts": "Produits populaires", "newestProducts": "Produits les plus recentsProduits" } From c0c9b3766752b4c936a8bec864d139a082fb112c Mon Sep 17 00:00:00 2001 From: Jorge Moya Date: Wed, 28 Aug 2024 10:32:46 -0500 Subject: [PATCH 02/30] refactor: StoreSelector --- core/app/[locale]/store-selector/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/app/[locale]/store-selector/page.tsx b/core/app/[locale]/store-selector/page.tsx index a17b2b48d..65ce19400 100644 --- a/core/app/[locale]/store-selector/page.tsx +++ b/core/app/[locale]/store-selector/page.tsx @@ -33,7 +33,7 @@ interface Props { export default async function StoreSelector({ params: { locale: selectedLocale } }: Props) { unstable_setRequestLocale(selectedLocale); - const t = await getTranslations('StoreSelector'); + const t = await getTranslations({ locale: selectedLocale, namespace: 'StoreSelector' }); const { data } = await client.fetch({ document: StoreSelectorPageQuery, From 25445b0bd5406b7362090b602ce407e3c1cd8b1d Mon Sep 17 00:00:00 2001 From: Jorge Moya Date: Wed, 28 Aug 2024 10:39:23 -0500 Subject: [PATCH 03/30] refactor: maintenance --- core/app/[locale]/maintenance/page.tsx | 18 ++++++++++++++---- core/messages/en.json | 4 ++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/core/app/[locale]/maintenance/page.tsx b/core/app/[locale]/maintenance/page.tsx index d5ecde3e3..0a34fa534 100644 --- a/core/app/[locale]/maintenance/page.tsx +++ b/core/app/[locale]/maintenance/page.tsx @@ -1,10 +1,12 @@ import { Phone } from 'lucide-react'; +import { getTranslations, unstable_setRequestLocale } from 'next-intl/server'; import { ReactNode } from 'react'; import { client } from '~/client'; import { graphql } from '~/client/graphql'; import { StoreLogo } from '~/components/store-logo'; import { StoreLogoFragment } from '~/components/store-logo/fragment'; +import { LocaleType } from '~/i18n'; const MaintenancePageQuery = graphql( ` @@ -31,7 +33,15 @@ const Container = ({ children }: { children: ReactNode }) => (
{children}
); -export default async function Maintenance() { +interface Props { + params: { locale: LocaleType }; +} + +export default async function Maintenance({ params: { locale } }: Props) { + unstable_setRequestLocale(locale); + + const t = await getTranslations({ locale, namespace: 'Maintenance' }); + const { data } = await client.fetch({ document: MaintenancePageQuery, }); @@ -41,7 +51,7 @@ export default async function Maintenance() { if (!storeSettings) { return ( -

We are down for maintenance

+

{t('message')}

); } @@ -52,13 +62,13 @@ export default async function Maintenance() { -

We are down for maintenance

+

{t('message')}

{Boolean(statusMessage) &&

{statusMessage}

} {contact && (
-

You can contact us at:

+

{t('contactUs')}

{t('heading')}

{t('message')}

- + - {featuredProducts.length ? ( -
-

{t('featuredProducts')}

-
- {featuredProducts.map((product) => ( - - - - ))} -
-
- ) : null} +