2023-04-07 17:33:45 +02:00
|
|
|
// Dependencies
|
|
|
|
import { useRouter } from 'next/router'
|
|
|
|
import { useTranslation } from 'next-i18next'
|
|
|
|
import Link from 'next/link'
|
|
|
|
// Components
|
2023-04-16 10:45:36 +02:00
|
|
|
import { ModalWrapper } from 'shared/components/wrappers/modal.mjs'
|
2023-04-07 17:33:45 +02:00
|
|
|
// Languages
|
|
|
|
import en from 'site/public/locales/en/locales.json'
|
|
|
|
import es from 'site/public/locales/es/locales.json'
|
|
|
|
import de from 'site/public/locales/de/locales.json'
|
|
|
|
import fr from 'site/public/locales/fr/locales.json'
|
|
|
|
import nl from 'site/public/locales/nl/locales.json'
|
|
|
|
|
|
|
|
export const ns = ['locales']
|
|
|
|
|
|
|
|
const translations = {
|
|
|
|
en: en.en,
|
|
|
|
es: es.es,
|
|
|
|
nl: nl.nl,
|
|
|
|
de: de.de,
|
|
|
|
fr: fr.fr,
|
|
|
|
}
|
|
|
|
|
2023-04-16 10:45:36 +02:00
|
|
|
export const ModalLocalePicker = ({ app, iconOnly = false, bottom = false }) => {
|
2023-04-07 17:33:45 +02:00
|
|
|
const { t } = useTranslation(ns)
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
return (
|
2023-04-16 10:45:36 +02:00
|
|
|
<ModalWrapper app={app}>
|
|
|
|
<div className="grid gap-2 p-4 grid-cols-1 max-w-lg w-full">
|
|
|
|
<h2>{t('locales:chooseYourLanguage')}</h2>
|
|
|
|
{router.locales.map((locale) => (
|
|
|
|
<Link
|
|
|
|
href={
|
|
|
|
locale === router.defaultLocale ? `/${router.asPath}` : `/${locale}/${router.asPath}`
|
|
|
|
}
|
|
|
|
key={locale}
|
|
|
|
locale={locale}
|
|
|
|
className="btn btn-lg btn-primary grow"
|
|
|
|
>
|
|
|
|
<span>{t(locale)}</span>
|
|
|
|
<span className="grow"></span>
|
|
|
|
<span>{translations[locale]}</span>
|
|
|
|
</Link>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</ModalWrapper>
|
2023-04-07 17:33:45 +02:00
|
|
|
)
|
|
|
|
}
|