From 57c718f3885544b6f7b6f2e0f5ed1ac526466061 Mon Sep 17 00:00:00 2001 From: paolosantarsiero Date: Sun, 19 Jan 2025 12:34:04 +0100 Subject: [PATCH] feat: add translations without routing --- app/checkout/page.tsx | 14 ++++---- app/layout.tsx | 35 +++++++++++-------- app/page.tsx | 22 ++++++++++-- app/product/[name]/page.tsx | 8 ++--- app/profile/@user/orders/page.tsx | 4 ++- app/profile/@user/page.tsx | 4 ++- app/profile/layout.tsx | 10 +++--- assets/images/fiori.png | Bin 0 -> 185405 bytes assets/images/man-wild.png | Bin 0 -> 468868 bytes components/cart/add-to-cart.tsx | 4 ++- components/cart/modal.tsx | 11 +++--- components/product/variant-selector.tsx | 4 ++- global.d.ts | 8 +++++ i18n/request.ts | 11 ++++++ messages/en.json | 42 +++++++++++++++++++++++ messages/it.json | 43 ++++++++++++++++++++++++ next.config.ts | 14 +++++++- package.json | 1 + pnpm-lock.yaml | 43 ++++++++++++++++++++++++ tsconfig.json | 2 +- 20 files changed, 239 insertions(+), 41 deletions(-) create mode 100644 assets/images/fiori.png create mode 100644 assets/images/man-wild.png create mode 100644 global.d.ts create mode 100644 i18n/request.ts create mode 100644 messages/en.json create mode 100644 messages/it.json diff --git a/app/checkout/page.tsx b/app/checkout/page.tsx index 7c0f6897f..770ec8c82 100644 --- a/app/checkout/page.tsx +++ b/app/checkout/page.tsx @@ -9,6 +9,7 @@ import Price from 'components/price'; import { Billing } from 'lib/woocomerce/models/billing'; import { PaymentGateways } from 'lib/woocomerce/models/payment'; import { Shipping } from 'lib/woocomerce/models/shipping'; +import { useTranslations } from 'next-intl'; import { useRouter } from 'next/navigation'; import { useEffect, useState } from 'react'; import { z } from 'zod'; @@ -26,6 +27,7 @@ const shippingSchema = z.object({ }); export default function CheckoutPage() { + const t = useTranslations('Checkout'); const { cart } = useCart(); const router = useRouter(); const { checkout, setShipping, setBilling, setPayment } = useCheckout(); @@ -70,7 +72,7 @@ export default function CheckoutPage() { return (
-

Checkout

+

{t('title')}

-

Total

+

{t('total')}

- + { const updatedShipping = { @@ -126,10 +128,10 @@ export default function CheckoutPage() { error={error} /> setSameBilling(v)} className="mt-2"> - Hai bisogno di fatturazione? + {t('billingCheckbox')} - + { const updatedBilling = { @@ -141,7 +143,7 @@ export default function CheckoutPage() { }} /> - +
+ - - - - -
- {children} - - -
-
-
-