Agregar soporte multi idioma (es-AR, es-419, pt-BR, en)

- Una página estática por idioma: / (es-AR), /es/, /pt/ y /en/.
- Textos en src/_data/strings/<idioma>.json y lista de idiomas en locales.json.
- Detección del idioma del navegador en / (fallback a inglés) y selector
  manual en header y menú mobile; la elección se guarda en localStorage.
- SEO por idioma: lang, canonical, hreflang, og:locale, JSON-LD y sitemap.
- nginx: no-cache para todas las páginas HTML.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jose Selesan
2026-11-03 09:11:01 -03:00
parent 01e31ddbbd
commit caac6fa7e4
23 changed files with 848 additions and 255 deletions

View File

@@ -1,7 +1,7 @@
<header class="sticky top-0 z-50 border-b border-slate-200/70 bg-white/80 backdrop-blur-lg dark:border-slate-800 dark:bg-slate-950/80">
<nav class="mx-auto flex h-16 max-w-7xl items-center justify-between px-4 sm:px-6 lg:px-8" aria-label="Navegación principal">
<nav class="mx-auto flex h-16 max-w-7xl items-center justify-between px-4 sm:px-6 lg:px-8" aria-label="{{ t.ui.mainNav }}">
<!-- Logo -->
<a href="/" class="flex items-center" aria-label="{{ site.name }} — inicio">
<a href="/" class="flex items-center" aria-label="{{ site.name }} — {{ t.ui.home }}">
<img src="/assets/logotipo-y-organica.svg" alt="{{ site.name }}" class="h-12 w-auto dark:hidden" width="252" height="83" />
<img src="/assets/logotipo-y-organica-oscuro.svg" alt="" class="hidden h-12 w-auto dark:block" width="252" height="83" />
</a>
@@ -9,7 +9,7 @@
<!-- Desktop links -->
<div class="hidden items-center gap-8 md:flex">
{% for item in site.nav %}
<a href="{{ item.href }}" class="text-sm font-medium text-slate-600 transition hover:text-brand-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-2 dark:text-slate-300 dark:hover:text-brand-400 dark:focus-visible:ring-offset-slate-950">{{ item.label }}</a>
<a href="{{ item.href }}" class="text-sm font-medium text-slate-600 transition hover:text-brand-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-2 dark:text-slate-300 dark:hover:text-brand-400 dark:focus-visible:ring-offset-slate-950">{{ t.nav[item.key] }}</a>
{% endfor %}
</div>
@@ -17,14 +17,30 @@
<div class="flex items-center gap-3">
<!-- CTA -->
<a href="{{ site.app.login }}" class="hidden items-center gap-2 text-sm font-semibold text-slate-700 transition hover:text-brand-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-2 dark:text-slate-200 dark:hover:text-brand-400 dark:focus-visible:ring-offset-slate-950 sm:inline-flex">
Iniciar sesión
{{ t.ui.login }}
</a>
<a href="{{ site.app.signup }}" class="inline-flex items-center justify-center rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-semibold text-white shadow-lg shadow-brand-600/25 transition hover:bg-brand-700 focus:outline-none focus:ring-2 focus:ring-brand-500 focus:ring-offset-2 dark:focus:ring-offset-slate-950">
Crear cuenta
{{ t.ui.signup }}
</a>
<!-- Language switcher (desktop only) -->
<div class="relative hidden md:block">
<button id="lang-toggle" type="button" aria-label="{{ t.ui.changeLanguage }}" aria-haspopup="true" aria-expanded="false" aria-controls="lang-menu" class="inline-flex h-10 items-center gap-1.5 rounded-full border border-slate-200 px-3 text-sm font-semibold text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-2 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800 dark:hover:text-white dark:focus-visible:ring-offset-slate-950">
<svg class="h-5 w-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10" /><path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10Z" /></svg>
<span>{{ locale.short }}</span>
</button>
<div id="lang-menu" class="absolute right-0 mt-2 hidden w-56 overflow-hidden rounded-xl border border-slate-200 bg-white py-1 shadow-xl shadow-slate-900/10 dark:border-slate-700 dark:bg-slate-900 dark:shadow-black/40">
{% for l in locales %}
<a href="{{ l.path }}" hreflang="{{ l.htmlLang }}" lang="{{ l.htmlLang }}" data-lang="{{ l.code }}" {% if l.code == locale.code %}aria-current="true"{% endif %} class="flex items-center justify-between gap-3 px-4 py-2.5 text-sm transition hover:bg-slate-100 focus:outline-none focus-visible:bg-slate-100 dark:hover:bg-slate-800 dark:focus-visible:bg-slate-800 {% if l.code == locale.code %}font-semibold text-brand-700 dark:text-brand-300{% else %}text-slate-700 dark:text-slate-200{% endif %}">
{{ l.label }}
{% if l.code == locale.code %}<svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5" /></svg>{% endif %}
</a>
{% endfor %}
</div>
</div>
<!-- Dark mode toggle (desktop only) -->
<button id="theme-toggle" type="button" aria-label="Cambiar tema claro/oscuro" class="hidden h-10 w-10 items-center justify-center rounded-full border border-slate-200 text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-2 md:inline-flex dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800 dark:hover:text-white dark:focus-visible:ring-offset-slate-950">
<button id="theme-toggle" type="button" aria-label="{{ t.ui.themeToggle }}" class="hidden h-10 w-10 items-center justify-center rounded-full border border-slate-200 text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-2 md:inline-flex dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800 dark:hover:text-white dark:focus-visible:ring-offset-slate-950">
<!-- Sun icon (shown in dark mode to switch to light) -->
<svg id="icon-sun" class="hidden h-5 w-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<circle cx="12" cy="12" r="4" />
@@ -37,7 +53,7 @@
</button>
<!-- Menu toggle (mobile only, far right) -->
<button id="menu-toggle" type="button" aria-label="Abrir menú" aria-expanded="false" aria-controls="mobile-menu" class="inline-flex h-10 w-10 items-center justify-center rounded-full border border-slate-200 text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-2 md:hidden dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800 dark:hover:text-white dark:focus-visible:ring-offset-slate-950">
<button id="menu-toggle" type="button" aria-label="{{ t.ui.openMenu }}" data-label-open="{{ t.ui.openMenu }}" data-label-close="{{ t.ui.closeMenu }}" aria-expanded="false" aria-controls="mobile-menu" class="inline-flex h-10 w-10 items-center justify-center rounded-full border border-slate-200 text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-2 md:hidden dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800 dark:hover:text-white dark:focus-visible:ring-offset-slate-950">
<svg id="icon-menu" class="h-5 w-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 6h16M4 12h16M4 18h16" /></svg>
<svg id="icon-close" class="hidden h-5 w-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18" /></svg>
</button>
@@ -49,8 +65,8 @@
<div class="space-y-1 px-4 py-4 sm:px-6">
<!-- Dark mode toggle (mobile) -->
<div class="flex items-center justify-between gap-4 border-b border-slate-200/70 px-3 pb-3 dark:border-slate-800">
<span class="text-base font-medium text-slate-700 dark:text-slate-200">Tema</span>
<button id="theme-toggle-mobile" type="button" aria-label="Cambiar tema claro/oscuro" class="inline-flex h-10 w-10 items-center justify-center rounded-full border border-slate-200 text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-2 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800 dark:hover:text-white dark:focus-visible:ring-offset-slate-950">
<span class="text-base font-medium text-slate-700 dark:text-slate-200">{{ t.ui.theme }}</span>
<button id="theme-toggle-mobile" type="button" aria-label="{{ t.ui.themeToggle }}" class="inline-flex h-10 w-10 items-center justify-center rounded-full border border-slate-200 text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-2 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800 dark:hover:text-white dark:focus-visible:ring-offset-slate-950">
<svg id="icon-sun-mobile" class="hidden h-5 w-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<circle cx="12" cy="12" r="4" />
<path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41" />
@@ -60,11 +76,20 @@
</svg>
</button>
</div>
<!-- Language switcher (mobile) -->
<div class="border-b border-slate-200/70 px-3 py-3 dark:border-slate-800">
<span class="text-base font-medium text-slate-700 dark:text-slate-200">{{ t.ui.language }}</span>
<div class="mt-3 grid grid-cols-2 gap-2">
{% for l in locales %}
<a href="{{ l.path }}" hreflang="{{ l.htmlLang }}" lang="{{ l.htmlLang }}" data-lang="{{ l.code }}" {% if l.code == locale.code %}aria-current="true"{% endif %} class="rounded-lg border px-3 py-2 text-center text-sm transition focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 {% if l.code == locale.code %}border-brand-500 bg-brand-50 font-semibold text-brand-700 dark:border-brand-400 dark:bg-brand-500/15 dark:text-brand-300{% else %}border-slate-200 text-slate-700 hover:bg-slate-100 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800{% endif %}">{{ l.label }}</a>
{% endfor %}
</div>
</div>
{% for item in site.nav %}
<a href="{{ item.href }}" class="block rounded-lg px-3 py-2.5 text-base font-medium text-slate-700 transition hover:bg-slate-100 hover:text-brand-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 dark:text-slate-200 dark:hover:bg-slate-800 dark:hover:text-brand-400" data-menu-link>{{ item.label }}</a>
<a href="{{ item.href }}" class="block rounded-lg px-3 py-2.5 text-base font-medium text-slate-700 transition hover:bg-slate-100 hover:text-brand-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 dark:text-slate-200 dark:hover:bg-slate-800 dark:hover:text-brand-400" data-menu-link>{{ t.nav[item.key] }}</a>
{% endfor %}
<div class="pt-3">
<a href="{{ site.app.login }}" class="block rounded-lg px-3 py-2.5 text-base font-medium text-slate-700 transition hover:bg-slate-100 hover:text-brand-600 dark:text-slate-200 dark:hover:bg-slate-800 dark:hover:text-brand-400" data-menu-link>Iniciar sesión</a>
<a href="{{ site.app.login }}" class="block rounded-lg px-3 py-2.5 text-base font-medium text-slate-700 transition hover:bg-slate-100 hover:text-brand-600 dark:text-slate-200 dark:hover:bg-slate-800 dark:hover:text-brand-400" data-menu-link>{{ t.ui.login }}</a>
</div>
</div>
</div>