Skip to content

Commit b6c666b

Browse files
TiZoriiViktorSvertoka
authored andcommitted
fix(i18n): correct translation keys and localization in shop pages
- Replace confusing error.order with success.orderLabel in checkout success page heading - Localize boolean stockRestored display (yes/no instead of true/false) in order details - Fix active state detection for shop category links in mobile menu using search params - Add missing translation keys (orderLabel, yes, no) to all locales (en, uk, pl)
1 parent fb8f89a commit b6c666b

8 files changed

Lines changed: 60 additions & 23 deletions

File tree

frontend/app/[locale]/shop/checkout/error/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export default async function CheckoutErrorPage({
136136
id="checkout-error-title"
137137
className="text-2xl font-bold text-foreground"
138138
>
139-
{t('errors.unableToLoadOrder')}
139+
{t('errors.unableToLoad')}
140140
</h1>
141141
<p className="mt-2 text-sm text-muted-foreground">
142142
{t('errors.tryAgainLater')}
@@ -219,7 +219,7 @@ export default async function CheckoutErrorPage({
219219
href={`/shop/checkout/payment/${order.id}`}
220220
className="inline-flex items-center justify-center rounded-md bg-accent px-4 py-2 text-sm font-semibold uppercase tracking-wide text-accent-foreground hover:bg-accent/90"
221221
>
222-
{t('actions.retryPayment')}
222+
{t('error.retryPayment')}
223223
</Link>
224224
) : null}
225225

frontend/app/[locale]/shop/checkout/success/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export default async function CheckoutSuccessPage({
168168
id="order-title"
169169
className="mt-2 text-3xl font-bold text-foreground"
170170
>
171-
{t('error.order')} #{order.id.slice(0, 8)}
171+
{t('success.orderLabel')} #{order.id.slice(0, 8)}
172172
</h1>
173173

174174
<p className="mt-2 text-sm text-muted-foreground">

frontend/app/[locale]/shop/orders/[id]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export default async function OrderDetailPage({
114114
const user = await getCurrentUser();
115115
if (!user) {
116116
redirect(
117-
`/${locale}/login?next=${encodeURIComponent(
117+
`/${locale}/login?returnTo=${encodeURIComponent(
118118
`/${locale}/shop/orders/${id}`
119119
)}`
120120
);
@@ -284,7 +284,7 @@ export default async function OrderDetailPage({
284284
<div>
285285
<dt className="text-xs opacity-80">{t('stockRestored')}</dt>
286286
<dd className="text-sm">
287-
{order.stockRestored ? 'true' : 'false'}
287+
{order.stockRestored ? t('yes') : t('no')}
288288
</dd>
289289
</div>
290290
<div>

frontend/app/[locale]/shop/orders/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export default async function MyOrdersPage({
113113

114114
const user = await getCurrentUser();
115115
if (!user) {
116-
redirect(`/login?next=${encodeURIComponent(`/shop/orders`)}`);
116+
redirect(`/${locale}/login?returnTo=${encodeURIComponent(`/${locale}/shop/orders`)}`);
117117
}
118118

119119
let rows: Array<{

frontend/components/header/AppMobileMenu.tsx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { Menu, X, LogIn, ShoppingBag, Home } from 'lucide-react';
44
import { useEffect, useMemo, useState } from 'react';
55
import { useTranslations } from 'next-intl';
6+
import { useSearchParams } from 'next/navigation';
67
import { Link, usePathname } from '@/i18n/routing';
78

89
import { SITE_LINKS } from '@/lib/navigation';
@@ -30,6 +31,8 @@ export function AppMobileMenu({
3031
const tCategories = useTranslations('shop.catalog.categories');
3132
const tProducts = useTranslations('shop.products');
3233
const pathname = usePathname();
34+
const searchParams = useSearchParams();
35+
const currentCategory = searchParams.get('category');
3336
const [open, setOpen] = useState(false);
3437
const [isAnimating, setIsAnimating] = useState(false);
3538

@@ -59,10 +62,10 @@ export function AppMobileMenu({
5962
}, [open]);
6063

6164
const shopLinks = useMemo(() => [
62-
{ href: '/shop/products', label: tProducts('title') },
63-
{ href: '/shop/products?category=apparel', label: tCategories('apparel') },
64-
{ href: '/shop/products?category=lifestyle', label: tCategories('lifestyle') },
65-
{ href: '/shop/products?category=collectibles', label: tCategories('collectibles') },
65+
{ href: '/shop/products', label: tProducts('title'), category: null },
66+
{ href: '/shop/products?category=apparel', label: tCategories('apparel'), category: 'apparel' },
67+
{ href: '/shop/products?category=lifestyle', label: tCategories('lifestyle'), category: 'lifestyle' },
68+
{ href: '/shop/products?category=collectibles', label: tCategories('collectibles'), category: 'collectibles' },
6669
], [tProducts, tCategories]);
6770

6871
const links = useMemo(() => {
@@ -147,16 +150,20 @@ export function AppMobileMenu({
147150
<HeaderButton href="/" icon={Home} onClick={close}>
148151
{t('home')}
149152
</HeaderButton>
150-
{links.map(link => (
151-
<Link
152-
key={link.href}
153-
href={link.href}
154-
onClick={close}
155-
className={linkClass(pathname === link.href)}
156-
>
157-
{'labelKey' in link ? t(link.labelKey) : link.label}
158-
</Link>
159-
))}
153+
{links.map(link => {
154+
const isActive = pathname === '/shop/products' &&
155+
('category' in link ? link.category === currentCategory : currentCategory === null);
156+
return (
157+
<Link
158+
key={link.href}
159+
href={link.href}
160+
onClick={close}
161+
className={linkClass(isActive)}
162+
>
163+
{'labelKey' in link ? t(link.labelKey) : link.label}
164+
</Link>
165+
);
166+
})}
160167
</>
161168
) : null}
162169

frontend/messages/en.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,9 @@
454454
"checkout": {
455455
"errors": {
456456
"missingOrderId": "Missing order id",
457+
"missingOrderIdDescription": "We couldn't identify your order. Please return to your cart or browse products.",
457458
"orderNotFound": "Order not found",
459+
"orderNotFoundDescription": "We couldn't find this order. It may have been removed or never existed.",
458460
"invalidOrder": "Invalid order",
459461
"unableToLoad": "Unable to load order",
460462
"unableToCheckout": "Unable to start checkout right now.",
@@ -469,6 +471,7 @@
469471
},
470472
"success": {
471473
"title": "Thank you for your order",
474+
"orderLabel": "Order",
472475
"received": "We've received your order.",
473476
"paymentConfirmed": "Payment has been confirmed.",
474477
"paymentProcessing": "Payment is still being processed. This page will update automatically.",
@@ -482,13 +485,18 @@
482485
},
483486
"error": {
484487
"paymentFailed": "Payment failed",
488+
"paymentFailedDescription": "The payment for this order was not completed. You can try again or contact support.",
485489
"paymentUnclear": "Payment status unclear",
490+
"paymentUnclearDescription": "We could not confirm a payment failure for this order.",
486491
"notCompleted": "The payment for this order was not completed. You can try again or contact support.",
487492
"couldNotConfirm": "We could not confirm a payment failure for this order.",
488493
"orderDetails": "Order details",
489494
"order": "Order",
495+
"orderLabel": "Order",
490496
"total": "Total",
497+
"totalLabel": "Total",
491498
"status": "Status",
499+
"statusLabel": "Status",
492500
"backToCart": "Back to cart",
493501
"retryPayment": "Retry payment",
494502
"continueShopping": "Continue shopping"
@@ -563,7 +571,9 @@
563571
"product": "Product: {productId}",
564572
"quantity": "Quantity",
565573
"unitPrice": "Unit price",
566-
"lineTotal": "Line total"
574+
"lineTotal": "Line total",
575+
"yes": "Yes",
576+
"no": "No"
567577
}
568578
}
569579
},

frontend/messages/pl.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,9 @@
454454
"checkout": {
455455
"errors": {
456456
"missingOrderId": "Brak identyfikatora zamówienia",
457+
"missingOrderIdDescription": "Nie mogliśmy zidentyfikować twojego zamówienia. Wróć do koszyka lub przeglądaj produkty.",
457458
"orderNotFound": "Zamówienie nie znalezione",
459+
"orderNotFoundDescription": "Nie mogliśmy znaleźć tego zamówienia. Mogło zostać usunięte lub nigdy nie istniało.",
458460
"invalidOrder": "Nieprawidłowe zamówienie",
459461
"unableToLoad": "Nie można załadować zamówienia",
460462
"unableToCheckout": "Nie można rozpocząć procesu zakupu.",
@@ -469,6 +471,7 @@
469471
},
470472
"success": {
471473
"title": "Dziękujemy za zamówienie",
474+
"orderLabel": "Zamówienie",
472475
"received": "Otrzymaliśmy twoje zamówienie.",
473476
"paymentConfirmed": "Płatność została potwierdzona.",
474477
"paymentProcessing": "Płatność jest nadal przetwarzana. Ta strona zaktualizuje się automatycznie.",
@@ -482,13 +485,18 @@
482485
},
483486
"error": {
484487
"paymentFailed": "Płatność nie powiodła się",
488+
"paymentFailedDescription": "Płatność za to zamówienie nie została zakończona. Możesz spróbować ponownie lub skontaktować się z pomocą.",
485489
"paymentUnclear": "Status płatności nieznany",
490+
"paymentUnclearDescription": "Nie mogliśmy potwierdzić błędu płatności dla tego zamówienia.",
486491
"notCompleted": "Płatność za to zamówienie nie została zakończona. Możesz spróbować ponownie lub skontaktować się z pomocą.",
487492
"couldNotConfirm": "Nie mogliśmy potwierdzić błędu płatności dla tego zamówienia.",
488493
"orderDetails": "Szczegóły zamówienia",
489494
"order": "Zamówienie",
495+
"orderLabel": "Zamówienie",
490496
"total": "Razem",
497+
"totalLabel": "Razem",
491498
"status": "Status",
499+
"statusLabel": "Status",
492500
"backToCart": "Wróć do koszyka",
493501
"retryPayment": "Spróbuj ponownie",
494502
"continueShopping": "Kontynuuj zakupy"
@@ -563,7 +571,9 @@
563571
"product": "Produkt: {productId}",
564572
"quantity": "Ilość",
565573
"unitPrice": "Cena jednostkowa",
566-
"lineTotal": "Suma wiersza"
574+
"lineTotal": "Suma wiersza",
575+
"yes": "Tak",
576+
"no": "Nie"
567577
}
568578
}
569579
},

frontend/messages/uk.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,9 @@
454454
"checkout": {
455455
"errors": {
456456
"missingOrderId": "Відсутній ідентифікатор замовлення",
457+
"missingOrderIdDescription": "Ми не змогли ідентифікувати ваше замовлення. Будь ласка, поверніться до кошика або перегляньте товари.",
457458
"orderNotFound": "Замовлення не знайдено",
459+
"orderNotFoundDescription": "Ми не змогли знайти це замовлення. Можливо, його було видалено або воно ніколи не існувало.",
458460
"invalidOrder": "Недійсне замовлення",
459461
"unableToLoad": "Не вдається завантажити замовлення",
460462
"unableToCheckout": "Не вдається розпочати оформлення замовлення зараз.",
@@ -469,6 +471,7 @@
469471
},
470472
"success": {
471473
"title": "Дякуємо за ваше замовлення",
474+
"orderLabel": "Замовлення",
472475
"received": "Ми отримали ваше замовлення.",
473476
"paymentConfirmed": "Оплату підтверджено.",
474477
"paymentProcessing": "Оплата все ще обробляється. Ця сторінка оновиться автоматично.",
@@ -482,13 +485,18 @@
482485
},
483486
"error": {
484487
"paymentFailed": "Помилка оплати",
488+
"paymentFailedDescription": "Оплату цього замовлення не завершено. Ви можете спробувати ще раз або зв'язатися з підтримкою.",
485489
"paymentUnclear": "Статус оплати неясний",
490+
"paymentUnclearDescription": "Ми не змогли підтвердити помилку оплати для цього замовлення.",
486491
"notCompleted": "Оплату цього замовлення не завершено. Ви можете спробувати ще раз або зв'язатися з підтримкою.",
487492
"couldNotConfirm": "Ми не змогли підтвердити помилку оплати для цього замовлення.",
488493
"orderDetails": "Деталі замовлення",
489494
"order": "Замовлення",
495+
"orderLabel": "Замовлення",
490496
"total": "Всього",
497+
"totalLabel": "Всього",
491498
"status": "Статус",
499+
"statusLabel": "Статус",
492500
"backToCart": "Назад до кошика",
493501
"retryPayment": "Повторити оплату",
494502
"continueShopping": "Продовжити покупки"
@@ -563,7 +571,9 @@
563571
"product": "Товар: {productId}",
564572
"quantity": "Кількість",
565573
"unitPrice": "Ціна за одиницю",
566-
"lineTotal": "Всього за рядок"
574+
"lineTotal": "Всього за рядок",
575+
"yes": "Так",
576+
"no": "Ні"
567577
}
568578
}
569579
},

0 commit comments

Comments
 (0)