vienalatina/themes/vienalatina/layouts/partials/t.html
Claude ff8effaf3a
Fix a build break I shipped in the last commit
`{{ partial "t.html" (dict "key" "by" "lang" .Site.Language.Lang) }}`
inside `{{ with .Params.author }}`, where the dot is the author *string*.
`.Site` on a string is an execution error, so the build fails — and with
--panicOnWarning in the pipeline, the whole publish fails with it. Same
again for `faq`, where the dot is a slice.

It would have gone red on your first deploy: Salvador's post carries an
author.

My build check passed because every post in the fixture had neither an
author nor a faq, so the two broken branches were never rendered. That
is the actual mistake — not the dot, which is an easy slip, but checking
a change to an optional branch with content that never takes it. The
fixture now carries a post with author, author_url, faq, event, image,
ai_generated and pinned all set at once.

The rule is now "always `$.`" rather than "think about where you are":
`$` is the page in every context, a bare `.` is only the page at top
level, and the difference is invisible until a post happens to have the
field. All sixteen call sites converted, and a test holds every one of
them to it — proved by putting the bug back and watching it fail.

Also the doc comment in t.html, which still claimed eleven keys. My
replacement for it last commit silently matched nothing: I asserted on
every other replacement in that script and not on this one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
2026-10-14 13:19:08 +00:00

73 lines
4.2 KiB
HTML

{{- /* The handful of words the templates themselves say.
Everything else on this site is content and arrives already translated by
the pipeline. These are the labels around it — "Lugar", "Compartir" — and
they are a table rather than a reason to install i18n files and a
translation workflow for the theme.
What is below is the *default*. Gestión → Textos can say something else,
and that is read first, out of data/ui.yaml. The same defaults also live
in apps/board/strings/sitio.yaml so the screen can show them as
placeholders — two copies, unavoidably, because Hugo reads the repository
and the members area reads its own image and neither can read the other's
file. test_strings.py fails if they drift, the way brand.FACTORY is held
to the two `:root` blocks.
Usage: {{ partial "t.html" (dict "key" "place" "lang" $.Site.Language.Lang) }}
**`$.` and never a bare `.`** Inside a `{{ with }}` the dot is whatever
that block holds — a string, a slice — and `.Site` on a string fails the
build rather than producing a wrong word. Two call sites shipped that way
and the build only broke on a post that happened to carry an `author`.
`$` is the page everywhere, and a test holds every call site to it.
An unknown key returns itself, so a typo is visible on the page instead of
rendering as nothing. */ -}}
{{- $words := dict
"time" (dict "es" "Hora" "de" "Uhrzeit" "pt-br" "Hora")
"place" (dict "es" "Lugar" "de" "Ort" "pt-br" "Local")
"add" (dict "es" "Añadir a mi calendario" "de" "Zum Kalender hinzufügen" "pt-br" "Adicionar ao meu calendário")
"agenda" (dict "es" "Agenda" "de" "Termine" "pt-br" "Agenda")
"previous" (dict "es" "Mes anterior" "de" "Voriger Monat" "pt-br" "Mês anterior")
"next" (dict "es" "Mes siguiente" "de" "Nächster Monat" "pt-br" "Próximo mês")
"noevents" (dict "es" "No hay nada en este mes." "de" "In diesem Monat ist nichts geplant." "pt-br" "Nada marcado neste mês.")
"ai" (dict "es" "Generado con IA" "de" "Mit KI erstellt" "pt-br" "Gerado com IA")
"pinned" (dict "es" "Fijado" "de" "Angeheftet" "pt-br" "Fixado")
"share" (dict "es" "Compartir" "de" "Teilen" "pt-br" "Compartilhar")
"copylink" (dict "es" "Copiar enlace" "de" "Link kopieren" "pt-br" "Copiar link")
"copied" (dict "es" "Enlace copiado" "de" "Link kopiert" "pt-br" "Link copiado")
"askmasto" (dict "es" "¿En qué servidor de Mastodon tienes tu cuenta? Por ejemplo: mastodon.social"
"de" "Auf welchem Mastodon-Server hast du dein Konto? Zum Beispiel: mastodon.social"
"pt-br" "Em qual servidor do Mastodon está a sua conta? Por exemplo: mastodon.social")
"aifull" (dict "es" "Quien lo publicó marcó este texto como generado con inteligencia artificial."
"de" "Wer diesen Beitrag veröffentlicht hat, hat ihn als mit künstlicher Intelligenz erstellt gekennzeichnet."
"pt-br" "Quem publicou marcou este texto como gerado com inteligência artificial.")
"community" (dict "es" "Comunidad" "de" "Community" "pt-br" "Comunidade")
"menu" (dict "es" "Menú" "de" "Menü" "pt-br" "Menu")
"home" (dict "es" "Inicio" "de" "Start" "pt-br" "Início")
"back" (dict "es" "← Volver al inicio" "de" "← Zurück zur Startseite" "pt-br" "← Voltar ao início")
"by" (dict "es" "por" "de" "von" "pt-br" "por")
"faq" (dict "es" "Preguntas frecuentes" "de" "Häufige Fragen" "pt-br" "Perguntas frequentes")
-}}
{{- /* What Gestión → Textos has said instead, if anything. Read through
nested `with` rather than as site.Data.ui.<key>.<lang>, because on a site
with no data file that dotted chain is a field lookup on nil and fails the
build — which is the state every install starts in. Same shape, and the
same trap, as site-name.html. */ -}}
{{- $said := "" -}}
{{- with site.Data.ui -}}
{{- with index . $.key -}}
{{- with index . $.lang }}{{ $said = . }}{{ end -}}
{{- end -}}
{{- end -}}
{{- if $said -}}
{{- $said -}}
{{- else -}}
{{- $entry := index $words .key -}}
{{- if $entry -}}
{{- index $entry .lang | default (index $entry "es") -}}
{{- else -}}
{{- .key -}}
{{- end -}}
{{- end -}}