Almost finished translations

This commit is contained in:
Daniele Pancottini 2022-12-22 10:53:30 +01:00
parent 7fb332ad94
commit e561a9d59d
11 changed files with 673 additions and 362 deletions

View File

@ -9,6 +9,7 @@ import { Logo, Container } from '@components/ui'
import { I18nWidget } from '@components/common'
import ThemeSwitcher from '@components/ui/ThemeSwitcher'
import s from './Footer.module.css'
import navBarLinks from '../../../static_data/navBarLinks.json'
interface Props {
className?: string
@ -16,29 +17,18 @@ interface Props {
pages?: Page[]
}
const links = [
{
name: 'Home',
url: '/',
},
{
name: 'About',
url: '/about'
},
{
name: 'News',
url: '/news'
},
{
name: 'Contact',
url: '/contact'
}
]
interface FooterLink {
label: string
href: string
}
const Footer: FC<Props> = ({ className, pages }) => {
const { sitePages } = usePages(pages)
const rootClassName = cn(s.root, className)
const { locale = 'it' } = useRouter()
const links = navBarLinks[locale as keyof typeof navBarLinks]
return (
<footer className={rootClassName}>
<Container>
@ -55,7 +45,16 @@ const Footer: FC<Props> = ({ className, pages }) => {
</div>
<div className="col-span-1 lg:col-span-7">
<div className="grid md:grid-rows-4 md:grid-cols-3 md:grid-flow-col">
{[...links, ...sitePages].map((page) => (
{[...links].map((page: FooterLink) => (
<span key={page.href} className="py-3 md:py-0 md:pb-4">
<Link href={page.href!}>
<a className="text-accent-9 hover:text-accent-6 transition ease-in-out duration-150">
{page.label}
</a>
</Link>
</span>
))}
{[...sitePages].map((page) => (
<span key={page.url} className="py-3 md:py-0 md:pb-4">
<Link href={page.url!}>
<a className="text-accent-9 hover:text-accent-6 transition ease-in-out duration-150">

View File

@ -17,7 +17,7 @@ import { MenuSidebarView } from '@components/common/UserNav'
import type { Page } from '@commerce/types/page'
import type { Category } from '@commerce/types/site'
import type { Link as LinkProps } from '../UserNav/MenuSidebarView'
import navBarLinks from '../../../static_data/navBarLinks.json';
import navBarLinks from '../../../static_data/navBarLinks.json'
import Script from 'next/script'
const Loading = () => (
@ -111,13 +111,13 @@ const Layout: React.FC<Props> = ({
}) => {
const { acceptedCookies, onAcceptCookies } = useAcceptCookies()
const { locale = 'it' } = useRouter()
const navBarlinks = navBarLinks.links;
const navBarlinks = navBarLinks[locale as keyof typeof navBarLinks]
return (
<CommerceProvider locale={locale}>
<div className={cn(s.root)}>
<Navbar links={navBarlinks} />
<main className="fit">{children}</main>
<main>{children}</main>
<Footer pages={pageProps.pages} />
<ModalUI />
<CheckoutProvider>

View File

@ -1,57 +1,76 @@
import { Drawer, DrawerOverlay, DrawerContent, DrawerHeader, DrawerBody, Link, Box, Stack, Heading, Divider } from "@chakra-ui/react"
import React, { useEffect, useState } from "react"
import filtersData from '../../../static_data/navBarMenuData.json';
import NavBarFiltersItem from './NavBarFiltersItem';
import {
Drawer,
DrawerOverlay,
DrawerContent,
DrawerHeader,
DrawerBody,
Link,
Box,
Stack,
Heading,
Divider,
} from '@chakra-ui/react'
import { useRouter } from 'next/router'
import React, { useEffect, useState } from 'react'
import filtersData from '../../../static_data/navBarMenuData.json'
import NavBarFiltersItem from './NavBarFiltersItem'
export default function NavBarFiltersDrawer(props: {
onClose: () => void;
isOpen: boolean;
export default function NavBarFiltersDrawer(props: {
onClose: () => void
isOpen: boolean
}) {
const { locale = 'it' } = useRouter()
const [placement, setPlacement] = React.useState('left' as const)
const [regions, setRegions] = React.useState<NavItem[]>([]);
const [categories, setCategories] = React.useState<NavItem[]>([]);
const [placement, setPlacement] = React.useState('left' as const)
const [regions, setRegions] = React.useState<NavItem[]>([])
const [categories, setCategories] = React.useState<NavItem[]>([])
useEffect(() => {
setRegions(filtersData.regions);
setCategories(filtersData.categories);
}, []);
return (
<>
<Drawer placement={placement} onClose={props.onClose} isOpen={props.isOpen}>
<DrawerOverlay />
<DrawerContent>
<DrawerBody>
<Stack mt={5} direction={"column"} spacing={"20"}>
<Box>
<Heading size={"lg"} mb={5}>Regions</Heading>
{
regions.map(region => (
<NavBarFiltersItem key={region.label} {...region} />
))
}
</Box>
<Box>
<Heading mb={5} size={"lg"}>Categories</Heading>
{
categories.map(category => (
<NavBarFiltersItem key={category.label} {...category} />
))
}
</Box>
</Stack>
</DrawerBody>
</DrawerContent>
</Drawer>
</>
useEffect(() => {
setRegions(filtersData.regions)
setCategories(
filtersData.categories[locale as keyof typeof filtersData.categories]
)
}
interface NavItem {
label: string;
subLabel?: string;
children?: Array<NavItem>;
href?: string;
enabled: boolean;
};
}, [])
return (
<>
<Drawer
placement={placement}
onClose={props.onClose}
isOpen={props.isOpen}
>
<DrawerOverlay />
<DrawerContent>
<DrawerBody>
<Stack mt={5} direction={'column'} spacing={'20'}>
<Box>
<Heading size={'lg'} mb={5}>
{locale === 'it' ? 'Regioni' : 'Regions'}
</Heading>
{regions.map((region) => (
<NavBarFiltersItem key={region.label} {...region} />
))}
</Box>
<Box>
<Heading mb={5} size={'lg'}>
{locale === 'it' ? 'Categorie' : 'Categories'}
</Heading>
{categories.map((category) => (
<NavBarFiltersItem key={category.label} {...category} />
))}
</Box>
</Stack>
</DrawerBody>
</DrawerContent>
</Drawer>
</>
)
}
interface NavItem {
label: string
subLabel?: string
children?: Array<NavItem>
href?: string
enabled: boolean
}

View File

@ -17,12 +17,18 @@ interface NavbarProps {
}
const Navbar: FC<NavbarProps> = ({ links }) => {
const { isOpen: isOpenDrawer, onOpen: onOpenDrawer, onClose: onCloseDrawer } = useDisclosure()
const {
isOpen: isOpenDrawer,
onOpen: onOpenDrawer,
onClose: onCloseDrawer,
} = useDisclosure()
return (
<>
<NavBarFiltersDrawer onClose={onCloseDrawer} isOpen={isOpenDrawer} ></NavBarFiltersDrawer>
<NavBarFiltersDrawer
onClose={onCloseDrawer}
isOpen={isOpenDrawer}
></NavBarFiltersDrawer>
<NavbarRoot>
<Container clean className="mx-auto max-w-8xl px-6">
<div className={s.nav}>
@ -38,10 +44,13 @@ const Navbar: FC<NavbarProps> = ({ links }) => {
</Link>
{links?.map((l) => (
<Link href={l.href} key={l.href}>
{
l.label === 'Regions' ? (<a onClick={onOpenDrawer} className={s.link}>{l.label}</a>)
: <a className={s.link}>{l.label}</a>
}
{l.label === 'Regions' || l.label === 'Regioni' ? (
<a onClick={onOpenDrawer} className={s.link}>
{l.label}
</a>
) : (
<a className={s.link}>{l.label}</a>
)}
</Link>
))}
</nav>

View File

@ -40,7 +40,11 @@ const Searchbar: FC<Props> = ({ className, id = 'search' }) => {
<input
id={id}
className={s.input}
placeholder="Search for products..."
placeholder={
router.locale === 'en'
? 'Search for products...'
: 'Cerca Prodotti...'
}
defaultValue={router.query.q}
onKeyUp={handleKeyUp}
/>

View File

@ -13,6 +13,7 @@ import { Box, Stack, Text as ChakraText } from '@chakra-ui/react'
import { Metafield } from '@commerce/types/common'
import productDetailsMetafields from '../../../static_data/productDetailsMetafields.json'
import { useRouter } from 'next/router'
interface ProductSidebarProps {
product: Product
@ -24,6 +25,7 @@ const ProductSidebar: FC<ProductSidebarProps> = ({ product, className }) => {
const { openSidebar } = useUI()
const [loading, setLoading] = useState(false)
const [selectedOptions, setSelectedOptions] = useState<SelectedOptions>({})
const { locale = 'it' } = useRouter()
useEffect(() => {
selectDefaultOptionFromProduct(product, setSelectedOptions)
@ -56,7 +58,9 @@ const ProductSidebar: FC<ProductSidebarProps> = ({ product, className }) => {
<Box>
<Stack>
{productDetailsMetafields.metafields[0].names.map((meta: any) => (
{productDetailsMetafields.metafields[
locale as keyof typeof productDetailsMetafields.metafields
].map((meta: any) => (
<Box key={meta.key}>
<ChakraText
as={'span'}
@ -76,16 +80,22 @@ const ProductSidebar: FC<ProductSidebarProps> = ({ product, className }) => {
<div style={{ marginTop: 20 }}>
{process.env.COMMERCE_CART_ENABLED && (
<Button
aria-label="Add to Cart"
aria-label={
locale === 'en' ? 'Add to Cart' : 'Aggiungi al Carrello'
}
type="button"
className={s.button}
onClick={addToCart}
loading={loading}
disabled={variant?.availableForSale === false}
>
{variant?.availableForSale === false
? 'Not Available'
: 'Add To Cart'}
{locale === 'en'
? variant?.availableForSale === false
? 'Not Available'
: 'Add To Cart'
: variant?.availableForSale === false
? 'Non Disponibile'
: 'Aggiungi al Carrello'}
</Button>
)}
</div>

View File

@ -13,6 +13,7 @@ import ProductTag from '../ProductTag'
import ProductModel from '../ProductModel/ProductModel'
import Lightbox from 'yet-another-react-lightbox'
import 'yet-another-react-lightbox/styles.css'
import { useRouter } from 'next/router'
interface ProductViewProps {
product: Product
@ -37,6 +38,7 @@ const ProductView: FC<ProductViewProps> = ({ product, relatedProducts }) => {
?.pop()
const [isLightboxOpen, setLightboxOpen] = useState(false)
const { locale = 'it' } = useRouter()
return (
<>
@ -101,7 +103,9 @@ const ProductView: FC<ProductViewProps> = ({ product, relatedProducts }) => {
</div>
<hr className="mt-7 border-accent-2" />
<section className="py-12 px-6 mb-10">
<Text variant="sectionHeading">Related Products</Text>
<Text variant="sectionHeading">
{locale === 'en' ? 'Related Products' : 'Prodotti Correlati'}
</Text>
<div className={s.relatedProductsGrid}>
{relatedProducts.map((p) => (
<div

View File

@ -12,7 +12,7 @@ import { ProductView } from '@components/product'
import productDetailsMetafields from '../../static_data/productDetailsMetafields.json'
const withMetafields = productDetailsMetafields.metafields[0].names.map(
const withMetafields = productDetailsMetafields.metafields.it.map(
(metafield: any) => {
return {
namespace: metafield.namespace,

View File

@ -1,6 +1,24 @@
{
"links": [
"it": [
{
"label": "Regioni",
"href": "#"
},
{
"label": "Chi Siamo",
"href": "/about"
},
{
"label": "News",
"href": "/news"
},
{
"label": "Contatti",
"href": "/contact"
}
],
"en": [
{
"label": "Regions",
"href": "#"
@ -18,5 +36,4 @@
"href": "/contact"
}
]
}

View File

@ -1,215 +1,405 @@
{
"regions": [
"regions": [
{
"label": "Abruzzo",
"children": [
{
"label": "Abruzzo",
"children": [
{
"label": "Teramo",
"href": "#",
"enabled": true
},
{
"label": "Pescara",
"href": "#",
"enabled": true
},
{
"label": "Chieti",
"href": "#",
"enabled": true
}
],
"href": "/abruzzo",
"enabled": false
"label": "Teramo",
"href": "#",
"enabled": true
},
{
"label": "Pescara",
"href": "#",
"enabled": true
},
{
"label": "Chieti",
"href": "#",
"enabled": true
}
],
],
"href": "/abruzzo",
"enabled": false
}
],
"categories": [
{
"label": "Abbigliamento e Accessori",
"children": [
{
"label": "Abbigliamento Bambino",
"href": "#",
"enabled": true
},
{
"label": "Abbigliamento Donna",
"href": "#",
"enabled": true
},
{
"label": "Abbigliamento Uomo",
"href": "#",
"enabled": true
},
{
"label": "Bigiotteria",
"href": "#",
"enabled": true
},
{
"label": "Calzature e Borse",
"href": "#",
"enabled": true
},
{
"label": "Orologi e Preziosi",
"href": "#",
"enabled": true
}
],
"categories": {
"it": [
{
"label": "Abbigliamento e Accessori",
"children": [
{
"label": "Abbigliamento Bambino",
"href": "#",
"enabled": true
},
{
"label": "Casa",
"children": [
{
"label": "Elettrodomestici",
"href": "#",
"enabled": true
},
{
"label": "Giardino",
"href": "#",
"enabled": true
},
{
"label": "Lampade e Lampadari",
"href": "#",
"enabled": true
},
{
"label": "Mobili e Arredi",
"href": "#",
"enabled": true
},
{
"label": "Oggettistica Casa",
"href": "#",
"enabled": true
},
{
"label": "Tessuti",
"href": "#",
"enabled": true
}
],
},
{
"label": "Abbigliamento Donna",
"href": "#",
"enabled": true
},
{
"label": "Elettronica",
"children": [
{
"label": "Audio e Video",
"href": "#",
"enabled": true
},
{
"label": "Console e Videogiochi",
"href": "#",
"enabled": true
},
{
"label": "Fotografia",
"href": "#",
"enabled": true
},
{
"label": "Informatica",
"href": "#",
"enabled": true
},
{
"label": "Telefonia",
"href": "#",
"enabled": true
}
],
},
{
"label": "Abbigliamento Uomo",
"href": "#",
"enabled": true
},
{
"label": "Lavoro",
"children": [
{
"label": "Attrezzatura da Lavoro",
"href": "#",
"enabled": true
},
{
"label": "Ferramente e Bricolage",
"href": "#",
"enabled": true
},
{
"label": "Giardinaggio",
"href": "#",
"enabled": true
}
],
},
{
"label": "Bigiotteria",
"href": "#",
"enabled": true
},
{
"label": "Sport e Hobby",
"children": [
{
"label": "Animali",
"href": "#",
"enabled": true
},
{
"label": "Articoli Sportivi",
"href": "#",
"enabled": true
},
{
"label": "Giochi e Giocattoli",
"href": "#",
"enabled": true
},
{
"label": "Libri e Riviste",
"href": "#",
"enabled": true
},
{
"label": "Strumenti Musicali",
"href": "#",
"enabled": true
},
{
"label": "CD, DVD, Vinili",
"href": "#",
"enabled": true
}
],
},
{
"label": "Calzature e Borse",
"href": "#",
"enabled": true
},
{
"label": "Veicoli",
"children": [
{
"label": "Accessori auto, moto, biciclette",
"href": "#",
"enabled": true
},
{
"label": "Auto",
"href": "#",
"enabled": true
},
{
"label": "Biciclette",
"href": "#",
"enabled": true
},
{
"label": "Moto e Scooter",
"href": "#",
"enabled": true
}
],
},
{
"label": "Orologi e Preziosi",
"href": "#",
"enabled": true
}
}
],
"enabled": true
},
{
"label": "Casa",
"children": [
{
"label": "Elettrodomestici",
"href": "#",
"enabled": true
},
{
"label": "Giardino",
"href": "#",
"enabled": true
},
{
"label": "Lampade e Lampadari",
"href": "#",
"enabled": true
},
{
"label": "Mobili e Arredi",
"href": "#",
"enabled": true
},
{
"label": "Oggettistica Casa",
"href": "#",
"enabled": true
},
{
"label": "Tessuti",
"href": "#",
"enabled": true
}
],
"enabled": true
},
{
"label": "Elettronica",
"children": [
{
"label": "Audio e Video",
"href": "#",
"enabled": true
},
{
"label": "Console e Videogiochi",
"href": "#",
"enabled": true
},
{
"label": "Fotografia",
"href": "#",
"enabled": true
},
{
"label": "Informatica",
"href": "#",
"enabled": true
},
{
"label": "Telefonia",
"href": "#",
"enabled": true
}
],
"enabled": true
},
{
"label": "Lavoro",
"children": [
{
"label": "Attrezzatura da Lavoro",
"href": "#",
"enabled": true
},
{
"label": "Ferramente e Bricolage",
"href": "#",
"enabled": true
},
{
"label": "Giardinaggio",
"href": "#",
"enabled": true
}
],
"enabled": true
},
{
"label": "Sport e Hobby",
"children": [
{
"label": "Animali",
"href": "#",
"enabled": true
},
{
"label": "Articoli Sportivi",
"href": "#",
"enabled": true
},
{
"label": "Giochi e Giocattoli",
"href": "#",
"enabled": true
},
{
"label": "Libri e Riviste",
"href": "#",
"enabled": true
},
{
"label": "Strumenti Musicali",
"href": "#",
"enabled": true
},
{
"label": "CD, DVD, Vinili",
"href": "#",
"enabled": true
}
],
"enabled": true
},
{
"label": "Veicoli",
"children": [
{
"label": "Accessori auto, moto, biciclette",
"href": "#",
"enabled": true
},
{
"label": "Auto",
"href": "#",
"enabled": true
},
{
"label": "Biciclette",
"href": "#",
"enabled": true
},
{
"label": "Moto e Scooter",
"href": "#",
"enabled": true
}
],
"enabled": true
}
],
"en": [
{
"label": "Clothing and Accessories",
"children": [
{
"label": "Baby Clothing",
"href": "#",
"enabled": true
},
{
"label": "Women's Clothing",
"href": "#",
"enabled": true
},
{
"label": "Men's Clothing",
"href": "#",
"enabled": true
},
{
"label": "Jewellery",
"href": "#",
"enabled": true
},
{
"label": "Shoes and Bags",
"href": "#",
"enabled": true
},
{
"label": "Watches and Precious",
"href": "#",
"enabled": true
}
],
"enabled": true
},
{
"label": "House",
"children": [
{
"label": "Household Appliances",
"href": "#",
"enabled": true
},
{
"label": "Garden",
"href": "#",
"enabled": true
},
{
"label": "Lamps and Chandeliers",
"href": "#",
"enabled": true
},
{
"label": "Furniture and Furnishings",
"href": "#",
"enabled": true
},
{
"label": "Household Items",
"href": "#",
"enabled": true
},
{
"label": "Fabrics",
"href": "#",
"enabled": true
}
],
"enabled": true
},
{
"label": "Electronic",
"children": [
{
"label": "Audio and Video",
"href": "#",
"enabled": true
},
{
"label": "Console and Videogames",
"href": "#",
"enabled": true
},
{
"label": "Photography",
"href": "#",
"enabled": true
},
{
"label": "Computer Science",
"href": "#",
"enabled": true
},
{
"label": "Telephony",
"href": "#",
"enabled": true
}
],
"enabled": true
},
{
"label": "Work",
"children": [
{
"label": "Work Equipment",
"href": "#",
"enabled": true
},
{
"label": "Hardware and Crafts",
"href": "#",
"enabled": true
},
{
"label": "Gardening",
"href": "#",
"enabled": true
}
],
"enabled": true
},
{
"label": "Sport and Hobby",
"children": [
{
"label": "Animals",
"href": "#",
"enabled": true
},
{
"label": "Sporting Goods",
"href": "#",
"enabled": true
},
{
"label": "Games and Toys",
"href": "#",
"enabled": true
},
{
"label": "Books and Magazines",
"href": "#",
"enabled": true
},
{
"label": "Musical Instruments",
"href": "#",
"enabled": true
},
{
"label": "CD, DVD, Vinyl",
"href": "#",
"enabled": true
}
],
"enabled": true
},
{
"label": "Vehicles",
"children": [
{
"label": "Car, Motorcycle and Bicycle Accessories",
"href": "#",
"enabled": true
},
{
"label": "Car",
"href": "#",
"enabled": true
},
{
"label": "Bicycle",
"href": "#",
"enabled": true
},
{
"label": "Motorcycle and Scooter",
"href": "#",
"enabled": true
}
],
"enabled": true
}
]
}
}
}

View File

@ -1,69 +1,128 @@
{
"metafields": [
{
"locale": "it",
"names": [
{
"name": "Tipo",
"key": "tipo",
"namespace": "custom"
},
{
"name": "Materiale",
"key": "materiale",
"namespace": "custom"
},
{
"name": "Colore",
"key": "colore",
"namespace": "custom"
},
{
"name": "Condizioni Estetiche",
"key": "condizioni_estetiche",
"namespace": "custom"
},
{
"name": "Altezza",
"key": "altezza",
"namespace": "custom"
},
{
"name": "Spessore",
"key": "spessore",
"namespace": "custom"
},
{
"name": "Larghezza",
"key": "larghezza",
"namespace": "custom"
},
{
"name": "Peso",
"key": "peso",
"namespace": "custom"
},
{
"name": "Confezione e Accessori Originali",
"key": "confezione_accessori",
"namespace": "custom"
},
{
"name": "Descrizione",
"key": "descrizione",
"namespace": "custom"
},
{
"name": "Vintage",
"key": "vintage",
"namespace": "custom"
},
{
"name": "Made In",
"key": "made_in",
"namespace": "custom"
}
]
}
]
"metafields": {
"it": [
{
"name": "Tipo",
"key": "tipo",
"namespace": "custom"
},
{
"name": "Materiale",
"key": "materiale",
"namespace": "custom"
},
{
"name": "Colore",
"key": "colore",
"namespace": "custom"
},
{
"name": "Condizioni Estetiche",
"key": "condizioni_estetiche",
"namespace": "custom"
},
{
"name": "Altezza",
"key": "altezza",
"namespace": "custom"
},
{
"name": "Spessore",
"key": "spessore",
"namespace": "custom"
},
{
"name": "Larghezza",
"key": "larghezza",
"namespace": "custom"
},
{
"name": "Peso",
"key": "peso",
"namespace": "custom"
},
{
"name": "Confezione e Accessori Originali",
"key": "confezione_accessori",
"namespace": "custom"
},
{
"name": "Descrizione",
"key": "descrizione",
"namespace": "custom"
},
{
"name": "Vintage",
"key": "vintage",
"namespace": "custom"
},
{
"name": "Made In",
"key": "made_in",
"namespace": "custom"
}
],
"en": [
{
"name": "Type",
"key": "tipo",
"namespace": "custom"
},
{
"name": "Material",
"key": "materiale",
"namespace": "custom"
},
{
"name": "Color",
"key": "colore",
"namespace": "custom"
},
{
"name": "Cosmetic Condition",
"key": "condizioni_estetiche",
"namespace": "custom"
},
{
"name": "Height",
"key": "altezza",
"namespace": "custom"
},
{
"name": "Thickness",
"key": "spessore",
"namespace": "custom"
},
{
"name": "Width",
"key": "larghezza",
"namespace": "custom"
},
{
"name": "Weight",
"key": "peso",
"namespace": "custom"
},
{
"name": "Original Packaging and Accessories",
"key": "confezione_accessori",
"namespace": "custom"
},
{
"name": "Description",
"key": "descrizione",
"namespace": "custom"
},
{
"name": "Vintage",
"key": "vintage",
"namespace": "custom"
},
{
"name": "Made In",
"key": "made_in",
"namespace": "custom"
}
]
}
}