-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* checkpoint: issue with localeswitcher component * fix: prettify code for pr * fix: commit pr ready * fix: redirects from pages to next config file * fix: admin link on header component * fix: redirects moved to _app * fix: minor fixations * fix: html lang switch * fix: prettify for pr * fix: automatic redirect to /it * feat: Adds some translations & Salvatore Riccardi as community member --------- Co-authored-by: Coluzzi Andrea <[email protected]>
- Loading branch information
1 parent
5dc33c2
commit 1c7da39
Showing
25 changed files
with
418 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
fullname: Salvatore Riccardi | ||
bio: Developer | ||
picture: sriccardi.jpg | ||
linkedin: https://www.linkedin.com/in/salvatore-riccardi/ | ||
github: https://github.com/salvatorericcardi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"home": { | ||
"nextEventsTitle": "Next Events", | ||
"nextEventsSubtitle": "Save dates and don't make commitments for upcoming community events!", | ||
"previousEventsTitle": "Previous Events", | ||
"previousEventsSubtitle": "Too bad, these events have already taken place! Follow the page to stay updated on upcoming events.", | ||
"andManyOthers": "...and many others!" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"home": { | ||
"nextEventsTitle": "Prossimi Eventi", | ||
"nextEventsSubtitle": "Fissa le date e non prendere impegni per i prossimi eventi della community!", | ||
"previousEventsTitle": "Eventi Passati", | ||
"previousEventsSubtitle": "Peccato, questi eventi si sono già svolti! Segui la pagina per rimanere aggiornato sui prossimi appuntamenti.", | ||
"andManyOthers": "...e molti altri!" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const i18n = { | ||
defaultLocale: "it", | ||
locales: ["it", "en"], | ||
} as const; | ||
|
||
export type Locale = (typeof i18n)["locales"][number]; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
'use client'; | ||
import 'flag-icons'; | ||
import { MouseEvent, useState } from 'react'; | ||
import { useRouter } from 'next/router'; | ||
import { Locale, i18n } from 'i18n.config'; | ||
import { usePathname } from 'next/navigation'; | ||
|
||
export default function LocaleSwitcher(props: { | ||
lang: Locale; | ||
mobile: boolean; | ||
}) { | ||
const router = useRouter(); | ||
const pathname = usePathname(); | ||
|
||
const defaultLocale = i18n.defaultLocale; | ||
const [animation, setAnimation] = useState(''); | ||
const [locale, setLocale] = useState(props.lang); | ||
|
||
const toggle = (e: MouseEvent<HTMLDivElement>) => { | ||
const container = e.target as HTMLDivElement; | ||
const changeLocale = i18n.locales.filter( | ||
locale => locale !== props.lang | ||
)[0]; | ||
|
||
setLocale(changeLocale); | ||
setAnimation(props.lang === defaultLocale ? 'slide-out' : 'slide-in'); | ||
|
||
container.onanimationend = () => { | ||
const regex = /it|en/; | ||
|
||
if (regex.test(pathname)) { | ||
void router.replace(pathname.replace(regex, changeLocale)); | ||
} else { | ||
void router.replace(`/${changeLocale}${pathname}`); | ||
} | ||
}; | ||
}; | ||
|
||
return ( | ||
<div | ||
className={`${props.mobile ? 'flex flex-row px-3 py-2' : 'hidden p-4 items-center lg:flex lg:flex-row'} gap-x-1`} | ||
> | ||
<span | ||
className='fi fi-it' | ||
style={{ display: 'block', width: '32px', height: '16px' }} | ||
></span> | ||
<div | ||
className='cursor-pointer w-8 h-4 rounded' | ||
style={{ backgroundColor: 'rgb(71 85 105 / 1)' }} | ||
onClick={e => toggle(e)} | ||
> | ||
<div | ||
className={`bg-white w-1/2 h-full rounded-full ${locale} ${animation}`} | ||
/> | ||
</div> | ||
<span | ||
className='fi fi-gb' | ||
style={{ display: 'block', width: '32px', height: '16px' }} | ||
></span> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
.en { | ||
position: relative; | ||
left: calc(100% - 16px); | ||
} | ||
|
||
.it { | ||
position: relative; | ||
left: 0; | ||
} | ||
|
||
.slide-in { | ||
animation-name: slidein; | ||
animation-duration: 750ms; | ||
} | ||
|
||
.slide-out { | ||
animation-name: slideout; | ||
animation-duration: 750ms; | ||
} | ||
|
||
@keyframes slideout { | ||
from { | ||
left: 0%; | ||
} | ||
|
||
to { | ||
left: calc(100% - 16px); | ||
} | ||
} | ||
|
||
@keyframes slidein { | ||
from { | ||
left: calc(100% - 16px); | ||
} | ||
|
||
to { | ||
left: 0%; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.