| 1 | "use client"; |
| 2 | |
| 3 | import { useRouter, usePathname |
| 4 | import { useLocale } |
| 5 | |
| 6 | const locales = [ |
| 7 | { code: "en", |
| 8 | { code: "de", |
| 9 | ]; |
| 10 | |
| 11 | export default function LocaleSelector |
| 12 | const router = |
| 13 | const pathname = |
| 14 | const locale = |
| 15 | |
| 16 | const handleLocaleChange = |
| 17 | const newLocale = |
| 18 | const newPathname = |
| 19 | router.push(newPathname |
| 20 | }; |
| 21 | |
| 22 | return ( |
| 23 | <select |
| 24 | value={locale} |
| 25 | onChange={handleLocaleChange} |
| 26 | aria-label="Language" |
| 27 | className="cursor-pointer rounded-md border border-neutral-800 bg-neutral-900 px-2 py-1.5 text-xs text-neutral-400 outline-none hover:text-neutral-100" |
| 28 | > |
| 29 | {locales.map(( |
| 30 | <option |
| 31 | key={locale.code |
| 32 | value={locale.code |
| 33 | className="bg-neutral-900 text-neutral-100" |
| 34 | > |
| 35 | {locale.name} |
| 36 | </option> |
| 37 | ))} |
| 38 | </select> |
| 39 | ); |
| 40 | } |