diff --git a/01-frontend/public/locales/de/translation.json b/01-frontend/public/locales/de/translation.json index 2461abe..e87804f 100644 --- a/01-frontend/public/locales/de/translation.json +++ b/01-frontend/public/locales/de/translation.json @@ -1,12 +1,23 @@ { + "account": "Account", + "addToCart": "In den Warenkorb", + "addedToCart": "Produkt wurde erfolgreich dem Warenkorb hinzugefügt", "almostSoldOut": "Fast ausverkauft", "available": "Stück verfügbar", - "freeShipping": "Kostenloser Versand ab 50€ Bestellwert", + "categories": "Kategorien", + "checkout": "Zur Kasse", + "close": "Schließen", + "contact": "Kontakt", + "currentAccount": "Account des aktuellen Benutzers", + "freeShipping": "Kostenloser Versand ab 50 € Bestellwert", "inStock": "Verfügbar", + "logout": "Ausloggen", + "orders": "Bestellungen", "outOfStock": "Ausverkauft", "quantity": "Anzahl", "rateThisProduct": "Dieses Produkt bewerten", "ratingFrom": "Bewertung vom", "review": "Produktrezension (optional)", - "search": "Suchen..." + "search": "Suchen", + "submit": "Senden" } diff --git a/01-frontend/public/locales/en/translation.json b/01-frontend/public/locales/en/translation.json index a770bee..a9cbe86 100644 --- a/01-frontend/public/locales/en/translation.json +++ b/01-frontend/public/locales/en/translation.json @@ -1,12 +1,23 @@ { + "account": "Account", + "addToCart": "Add to cart", + "addedToCart": "Product added to shopping cart successfully", "almostSoldOut": "Almost sold out", "available": "items available", - "freeShipping": "Free shipping for orders over 50€", + "categories": "Categories", + "checkout": "Checkout", + "close": "Close", + "contact": "Contact", + "currentAccount": "Account of current user", + "freeShipping": "Free shipping for orders over 50 €", "inStock": "In stock", + "logout": "Logout", + "orders": "Orders", "outOfStock": "Out of stock", "quantity": "Quantity", "rateThisProduct": "Rate this product", "ratingFrom": "Rating from", "review": "Product review (optional)", - "search": "Search..." + "search": "Search", + "submit": "Submit" } diff --git a/01-frontend/src/helper/navbar/NavBar.tsx b/01-frontend/src/helper/navbar/NavBar.tsx index d152fa8..13b15a9 100644 --- a/01-frontend/src/helper/navbar/NavBar.tsx +++ b/01-frontend/src/helper/navbar/NavBar.tsx @@ -18,9 +18,6 @@ import { useNavigate } from 'react-router-dom'; import {useTranslation} from 'react-i18next'; import './NavBar.css'; -const pages = ['Categories', 'Checkout', 'Contact']; -const settings = ['Account', 'Orders', 'Logout']; - const Search = styled('div')(({ theme }) => ({ position: 'relative', borderRadius: theme.shape.borderRadius, @@ -70,6 +67,12 @@ export default function NavBar() { const [anchorElNav, setAnchorElNav] = React.useState(null); const [anchorElUser, setAnchorElUser] = React.useState(null); + const pageKeys = ['categories', 'checkout', 'contact']; + const settingKeys = ['account', 'orders', 'logout']; + + const pages = pageKeys.map(key => ({ key, label: t(key) })); + const settings = settingKeys.map(key => ({ key, label: t(key) })); + const handleOpenNavMenu = (event: React.MouseEvent) => { setAnchorElNav(event.currentTarget); }; @@ -87,7 +90,6 @@ export default function NavBar() { navigate(`/${link.toLowerCase()}`); }; - return ( @@ -116,15 +118,15 @@ export default function NavBar() { - {pages.map((page) => ( - handleCloseNavMenu(page)}> - {page} + {pages.map(({ key, label }) => ( + handleCloseNavMenu(key)}> + {label} ))} @@ -177,11 +179,11 @@ export default function NavBar() { {pages.map((page) => ( ))} @@ -207,9 +209,9 @@ export default function NavBar() { open={Boolean(anchorElUser)} onClose={handleCloseUserMenu} > - {settings.map((setting) => ( - handleCloseUserMenu(setting)}> - {setting} + {settings.map(({ key, label }) => ( + handleCloseUserMenu(key)}> + {label} ))} diff --git a/01-frontend/src/helper/productpage/ProductInfo.tsx b/01-frontend/src/helper/productpage/ProductInfo.tsx index 1fa69e2..8e86d5e 100644 --- a/01-frontend/src/helper/productpage/ProductInfo.tsx +++ b/01-frontend/src/helper/productpage/ProductInfo.tsx @@ -30,7 +30,7 @@ export default function ProductInfo({ item }: { item: Item }) { @@ -92,22 +92,22 @@ export default function ProductInfo({ item }: { item: Item }) { {item.discount > 0 ? ( <> - €{discountedPrice.toFixed(2)} + {discountedPrice.toFixed(2)} € - €{item.price.toFixed(2)} + {item.price.toFixed(2)} € - -{item.discount}% + -{item.discount} % ) : ( - €{item.price.toFixed(2)} + {item.price.toFixed(2)} € )} @@ -143,7 +143,7 @@ export default function ProductInfo({ item }: { item: Item }) { disabled={item.stock <= 0} fullWidth > - Add to Cart + {t('addToCart')} @@ -159,7 +159,7 @@ export default function ProductInfo({ item }: { item: Item }) { open={open} autoHideDuration={3000} onClose={handleClose} - message="Successfully added to basket" + message={t('addedToCart')} action={action} /> diff --git a/01-frontend/src/helper/productpage/Ratings.tsx b/01-frontend/src/helper/productpage/Ratings.tsx index 699ff23..97a35b9 100644 --- a/01-frontend/src/helper/productpage/Ratings.tsx +++ b/01-frontend/src/helper/productpage/Ratings.tsx @@ -31,7 +31,7 @@ export default function Ratings() { @@ -78,7 +78,7 @@ export default function Ratings() { className="rating-text-field" />