From 688bb7426d479339d61218d9667c6ad8725b0099 Mon Sep 17 00:00:00 2001 From: jamesqquick Date: Thu, 7 Nov 2024 13:40:01 -0600 Subject: [PATCH 1/2] chore: add localization to product detail add to cart button --- core/vibes/soul/sections/product-detail/index.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/vibes/soul/sections/product-detail/index.tsx b/core/vibes/soul/sections/product-detail/index.tsx index feaf6297f..8fafac735 100644 --- a/core/vibes/soul/sections/product-detail/index.tsx +++ b/core/vibes/soul/sections/product-detail/index.tsx @@ -1,6 +1,7 @@ import { Price, PriceLabel } from '@/vibes/soul/primitives/price-label'; import { Rating } from '@/vibes/soul/primitives/rating'; import { ProductGallery } from '@/vibes/soul/sections/product-detail/product-gallery'; +import { useTranslations } from 'next-intl'; import { ProductDetailForm, ProductDetailFormAction } from './product-detail-form'; import { Field } from './schema'; @@ -24,6 +25,8 @@ type Props = { }; export function ProductDetail({ product, action, fields }: Props) { + const t = useTranslations('Components.AddToCartButton'); + return (
@@ -53,7 +56,12 @@ export function ProductDetail({ product, action, fields }: Prop

{product.description}

)} - +
From 4b735e1a1285a95f9fde1470d6a97c0e3974b7f1 Mon Sep 17 00:00:00 2001 From: jamesqquick Date: Fri, 8 Nov 2024 11:30:00 -0600 Subject: [PATCH 2/2] chore: ProductDetail to accept ctaLabel prop instead of handling localization internally --- core/app/[locale]/(default)/product/[slug]/page.tsx | 5 ++++- core/vibes/soul/sections/product-detail/index.tsx | 7 +++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/app/[locale]/(default)/product/[slug]/page.tsx b/core/app/[locale]/(default)/product/[slug]/page.tsx index 4985bee45..1675ff418 100644 --- a/core/app/[locale]/(default)/product/[slug]/page.tsx +++ b/core/app/[locale]/(default)/product/[slug]/page.tsx @@ -74,6 +74,9 @@ export default async function Product({ params: { locale, slug }, searchParams } setRequestLocale(locale); const t = await getTranslations('Product'); + const c = await getTranslations('Components'); + + const ctaLabel = c('AddToCartButton.addToCart') const format = await getFormatter(); @@ -324,7 +327,7 @@ export default async function Product({ params: { locale, slug }, searchParams } return ( <> - + = { product: ProductDetailProduct; action: ProductDetailFormAction; fields: F[]; + ctaLabel: string; }; -export function ProductDetail({ product, action, fields }: Props) { - const t = useTranslations('Components.AddToCartButton'); +export function ProductDetail({ product, action, fields, ctaLabel }: Props) { return (
@@ -60,7 +59,7 @@ export function ProductDetail({ product, action, fields }: Prop action={action} fields={fields} productId={product.id} - ctaLabel={t('addToCart')} + ctaLabel={ctaLabel} />