2022-01-22 17:55:03 +01:00
|
|
|
import themes from 'shared/themes/index.js'
|
2022-01-27 18:07:37 +01:00
|
|
|
import LocaleIcon from 'shared/components/icons/i18n.js'
|
2022-02-06 19:16:49 +01:00
|
|
|
import { useRouter } from 'next/router'
|
|
|
|
import { useTranslation } from 'next-i18next'
|
|
|
|
import Link from 'next/link'
|
2022-02-06 13:17:42 +01:00
|
|
|
|
2022-02-06 19:16:49 +01:00
|
|
|
const LocalePicker = ({ app }) => {
|
|
|
|
const { t } = useTranslation(['locales'])
|
|
|
|
const router = useRouter()
|
2022-02-07 20:02:28 +01:00
|
|
|
|
2022-02-06 19:16:49 +01:00
|
|
|
return (
|
|
|
|
<div className="dropdown">
|
|
|
|
<div tabIndex="0" className={`
|
|
|
|
m-0 btn btn-neutral flex flex-row gap-2
|
|
|
|
sm:btn-ghost
|
|
|
|
hover:bg-neutral hover:border-neutral-content
|
|
|
|
`}>
|
|
|
|
<LocaleIcon />
|
|
|
|
<span>{t(router.locale)}</span>
|
|
|
|
</div>
|
|
|
|
<ul tabIndex="0" className="p-2 shadow menu dropdown-content bg-base-100 rounded-box w-52">
|
|
|
|
{router.locales.map(locale => (
|
|
|
|
<li key={locale}>
|
|
|
|
<Link href={router.asPath} locale={locale}>
|
|
|
|
<a className="btn btn-ghost text-base-content hover:bg-base-200">
|
|
|
|
<span className="text-base-content">
|
|
|
|
{t(locale)}
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
2022-01-28 18:27:20 +01:00
|
|
|
</div>
|
2022-02-06 19:16:49 +01:00
|
|
|
)
|
|
|
|
}
|
2022-01-22 17:55:03 +01:00
|
|
|
|
2022-01-27 18:07:37 +01:00
|
|
|
export default LocalePicker
|