4a783d165f
- components/Header.tsx (server, lee sesión): marca, nav (Inicio; login/register o account/logout según sesión), LanguageSwitcher y LogoutButton. - components/LanguageSwitcher.tsx (cliente): cambia de idioma conservando la ruta (next-intl usePathname/useRouter). components/LogoutButton.tsx (compartido). - components/Footer.tsx. app/[locale]/layout.tsx envuelve children con Header/Footer (columna min-h-screen). Se unifica el LogoutButton (se borra el de account/). - messages: namespace Nav. Verificado: home ES/EN con cabecera+nav+idioma+pie; enlaces locale-aware (/en/login); textos por idioma. Al leer sesión en el header, todas las rutas pasan a dinámicas. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
29 lines
779 B
TypeScript
29 lines
779 B
TypeScript
'use client'
|
|
|
|
import { useLocale } from 'next-intl'
|
|
import { usePathname, useRouter } from '@/i18n/navigation'
|
|
import { routing } from '@/i18n/routing'
|
|
|
|
const LABELS: Record<string, string> = { es: 'ES', en: 'EN' }
|
|
|
|
export function LanguageSwitcher() {
|
|
const locale = useLocale()
|
|
const pathname = usePathname() // sin prefijo de idioma
|
|
const router = useRouter()
|
|
|
|
return (
|
|
<select
|
|
value={locale}
|
|
onChange={(e) => router.replace(pathname, { locale: e.target.value })}
|
|
className="rounded border border-amber-900/60 bg-[#2c1e14] px-2 py-1 text-sm"
|
|
aria-label="language"
|
|
>
|
|
{routing.locales.map((loc) => (
|
|
<option key={loc} value={loc}>
|
|
{LABELS[loc] ?? loc.toUpperCase()}
|
|
</option>
|
|
))}
|
|
</select>
|
|
)
|
|
}
|