added translations

This commit is contained in:
Laura Dolibois
2025-05-25 12:56:09 +02:00
parent a8b781327b
commit 1ed31a4525
5 changed files with 53 additions and 29 deletions

View File

@@ -1,12 +1,23 @@
{ {
"account": "Account",
"addToCart": "In den Warenkorb",
"addedToCart": "Produkt wurde erfolgreich dem Warenkorb hinzugefügt",
"almostSoldOut": "Fast ausverkauft", "almostSoldOut": "Fast ausverkauft",
"available": "Stück verfügbar", "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", "inStock": "Verfügbar",
"logout": "Ausloggen",
"orders": "Bestellungen",
"outOfStock": "Ausverkauft", "outOfStock": "Ausverkauft",
"quantity": "Anzahl", "quantity": "Anzahl",
"rateThisProduct": "Dieses Produkt bewerten", "rateThisProduct": "Dieses Produkt bewerten",
"ratingFrom": "Bewertung vom", "ratingFrom": "Bewertung vom",
"review": "Produktrezension (optional)", "review": "Produktrezension (optional)",
"search": "Suchen..." "search": "Suchen",
"submit": "Senden"
} }

View File

@@ -1,12 +1,23 @@
{ {
"account": "Account",
"addToCart": "Add to cart",
"addedToCart": "Product added to shopping cart successfully",
"almostSoldOut": "Almost sold out", "almostSoldOut": "Almost sold out",
"available": "items available", "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", "inStock": "In stock",
"logout": "Logout",
"orders": "Orders",
"outOfStock": "Out of stock", "outOfStock": "Out of stock",
"quantity": "Quantity", "quantity": "Quantity",
"rateThisProduct": "Rate this product", "rateThisProduct": "Rate this product",
"ratingFrom": "Rating from", "ratingFrom": "Rating from",
"review": "Product review (optional)", "review": "Product review (optional)",
"search": "Search..." "search": "Search",
"submit": "Submit"
} }

View File

@@ -18,9 +18,6 @@ import { useNavigate } from 'react-router-dom';
import {useTranslation} from 'react-i18next'; import {useTranslation} from 'react-i18next';
import './NavBar.css'; import './NavBar.css';
const pages = ['Categories', 'Checkout', 'Contact'];
const settings = ['Account', 'Orders', 'Logout'];
const Search = styled('div')(({ theme }) => ({ const Search = styled('div')(({ theme }) => ({
position: 'relative', position: 'relative',
borderRadius: theme.shape.borderRadius, borderRadius: theme.shape.borderRadius,
@@ -70,6 +67,12 @@ export default function NavBar() {
const [anchorElNav, setAnchorElNav] = React.useState<null | HTMLElement>(null); const [anchorElNav, setAnchorElNav] = React.useState<null | HTMLElement>(null);
const [anchorElUser, setAnchorElUser] = React.useState<null | HTMLElement>(null); const [anchorElUser, setAnchorElUser] = React.useState<null | HTMLElement>(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<HTMLElement>) => { const handleOpenNavMenu = (event: React.MouseEvent<HTMLElement>) => {
setAnchorElNav(event.currentTarget); setAnchorElNav(event.currentTarget);
}; };
@@ -87,7 +90,6 @@ export default function NavBar() {
navigate(`/${link.toLowerCase()}`); navigate(`/${link.toLowerCase()}`);
}; };
return ( return (
<AppBar className="navbar"> <AppBar className="navbar">
<Container maxWidth="xl"> <Container maxWidth="xl">
@@ -116,15 +118,15 @@ export default function NavBar() {
<SearchIcon sx={{color: 'white'}}/> <SearchIcon sx={{color: 'white'}}/>
</SearchIconWrapper> </SearchIconWrapper>
<StyledInputBase <StyledInputBase
placeholder={t('search')} placeholder={t('search') + "..."}
inputProps={{ 'aria-label': 'search' }} inputProps={{ 'aria-label': t('search')}}
/> />
</Search> </Search>
<Box sx={{ flexGrow: 1, display: { xs: 'flex', md: 'none' } }}> <Box sx={{ flexGrow: 1, display: { xs: 'flex', md: 'none' } }}>
<IconButton <IconButton
size="large" size="large"
aria-label="account of current user" aria-label={t('currentAccount')}
aria-controls="menu-appbar" aria-controls="menu-appbar"
aria-haspopup="true" aria-haspopup="true"
onClick={handleOpenNavMenu} onClick={handleOpenNavMenu}
@@ -148,9 +150,9 @@ export default function NavBar() {
onClose={handleCloseNavMenu} onClose={handleCloseNavMenu}
sx={{ display: { xs: 'block', md: 'none' } }} sx={{ display: { xs: 'block', md: 'none' } }}
> >
{pages.map((page) => ( {pages.map(({ key, label }) => (
<MenuItem key={page} onClick={() => handleCloseNavMenu(page)}> <MenuItem key={key} onClick={() => handleCloseNavMenu(key)}>
<Typography sx={{ textAlign: 'center' }}>{page}</Typography> <Typography sx={{ textAlign: 'center' }}>{label}</Typography>
</MenuItem> </MenuItem>
))} ))}
</Menu> </Menu>
@@ -177,11 +179,11 @@ export default function NavBar() {
<Box sx={{ flexGrow: 1, display: { xs: 'none', md: 'flex' } }}> <Box sx={{ flexGrow: 1, display: { xs: 'none', md: 'flex' } }}>
{pages.map((page) => ( {pages.map((page) => (
<Button <Button
key={page} key={page.key}
onClick={() => handleCloseNavMenu(page)} onClick={() => handleCloseNavMenu(page.key)}
sx={{ my: 2, color: 'white', display: 'block' }} sx={{ my: 2, color: 'white', display: 'block' }}
> >
{page} {page.label}
</Button> </Button>
))} ))}
</Box> </Box>
@@ -207,9 +209,9 @@ export default function NavBar() {
open={Boolean(anchorElUser)} open={Boolean(anchorElUser)}
onClose={handleCloseUserMenu} onClose={handleCloseUserMenu}
> >
{settings.map((setting) => ( {settings.map(({ key, label }) => (
<MenuItem key={setting} onClick={() => handleCloseUserMenu(setting)}> <MenuItem key={key} onClick={() => handleCloseUserMenu(key)}>
<Typography sx={{ textAlign: 'center' }}>{setting}</Typography> <Typography sx={{ textAlign: 'center' }}>{label}</Typography>
</MenuItem> </MenuItem>
))} ))}
</Menu> </Menu>

View File

@@ -30,7 +30,7 @@ export default function ProductInfo({ item }: { item: Item }) {
<React.Fragment> <React.Fragment>
<IconButton <IconButton
size="small" size="small"
aria-label="close" aria-label={t('close')}
color="inherit" color="inherit"
onClick={handleClose} onClick={handleClose}
> >
@@ -92,22 +92,22 @@ export default function ProductInfo({ item }: { item: Item }) {
{item.discount > 0 ? ( {item.discount > 0 ? (
<> <>
<Typography variant="h4" color="green"> <Typography variant="h4" color="green">
{discountedPrice.toFixed(2)} {discountedPrice.toFixed(2)}
</Typography> </Typography>
<Typography <Typography
variant="h6" variant="h6"
color="text.secondary" color="text.secondary"
sx={{ textDecoration: 'line-through' }} sx={{ textDecoration: 'line-through' }}
> >
{item.price.toFixed(2)} {item.price.toFixed(2)}
</Typography> </Typography>
<Typography variant="h6" color="error"> <Typography variant="h6" color="error">
-{item.discount}% -{item.discount} %
</Typography> </Typography>
</> </>
) : ( ) : (
<Typography variant="h4" color="green"> <Typography variant="h4" color="green">
{item.price.toFixed(2)} {item.price.toFixed(2)}
</Typography> </Typography>
)} )}
</Stack> </Stack>
@@ -143,7 +143,7 @@ export default function ProductInfo({ item }: { item: Item }) {
disabled={item.stock <= 0} disabled={item.stock <= 0}
fullWidth fullWidth
> >
Add to Cart {t('addToCart')}
</Button> </Button>
</Stack> </Stack>
@@ -159,7 +159,7 @@ export default function ProductInfo({ item }: { item: Item }) {
open={open} open={open}
autoHideDuration={3000} autoHideDuration={3000}
onClose={handleClose} onClose={handleClose}
message="Successfully added to basket" message={t('addedToCart')}
action={action} action={action}
/> />

View File

@@ -31,7 +31,7 @@ export default function Ratings() {
<React.Fragment> <React.Fragment>
<IconButton <IconButton
size="small" size="small"
aria-label="close" aria-label={t('close')}
color="inherit" color="inherit"
onClick={handleClose} onClick={handleClose}
> >
@@ -78,7 +78,7 @@ export default function Ratings() {
className="rating-text-field" className="rating-text-field"
/> />
<Button variant="contained" color="primary" className="rating-button" onClick={handleRatingSubmit}> <Button variant="contained" color="primary" className="rating-button" onClick={handleRatingSubmit}>
Submit {t('submit')}
</Button> </Button>
</div> </div>
<div className='contact-divider-box'> <div className='contact-divider-box'>