Footer links stay Swedish when the Forgejo UI is set to English #333

Stängd
öppnade 2026-08-02 12:30:47 +00:00 av supernaut · 0 kommentarer
Ägare

The three Bitborg links in the Forgejo footer render in Swedish regardless of the UI language.
With the interface set to English, the footer still reads "Användarvillkor" and
"Integritetspolicy" next to correctly translated Forgejo strings ("Powered by Forgejo",
"Licenses").

Reproduce

curl -s -H 'Accept-Language: en-US,en;q=0.9' https://git.gitborg.se/explore/repos | grep -A4 right-links

The three links are byte-identical to the sv-SE response.

Cause

ansible/roles/forgejo/templates/custom/extra_links_footer.tmpl.j2:4-6 is plain HTML with
hardcoded Swedish labels. Forgejo's custom/templates/custom/* hook fragments are not routed
through the translation pipeline unless they ask for it explicitly. Nothing upstream is at
fault — this is our fragment.

Fix

Forgejo exposes ctx (and therefore ctx.Locale) to every template as a per-request funcmap
entry — modules/templates/htmlrenderer.go on the v16.0.1 tag — including custom/*
fragments, which are included with the full page context
(templates/base/footer_content.tmpl: {{template "custom/extra_links_footer" .}}). So the
fragment can branch on {{ctx.Locale.Lang}} (sv-SE / en-US) and emit the right label.

Use English wording that matches the portal's own navigation: Terms of Service and
Privacy Policy. Swedish output must stay exactly as it is today.

Do not try to add custom translation keys under custom/options/locale/: locale files are
read through a layered asset filesystem whose ReadFile returns the first matching layer and
stops (modules/options/base.go, modules/assetfs/layered.go), so a custom
locale_en-US.ini would replace the whole built-in English locale rather than extend it.

Done when

  • The English UI shows English labels and the Swedish UI is unchanged, verified with the two
    curl commands above against production.
  • Previewed through local/ (podman) before the production apply.

Part of gitborg/gitborg-docs#70.

The three Bitborg links in the Forgejo footer render in Swedish regardless of the UI language. With the interface set to English, the footer still reads "Användarvillkor" and "Integritetspolicy" next to correctly translated Forgejo strings ("Powered by Forgejo", "Licenses"). **Reproduce** ``` curl -s -H 'Accept-Language: en-US,en;q=0.9' https://git.gitborg.se/explore/repos | grep -A4 right-links ``` The three links are byte-identical to the `sv-SE` response. **Cause** `ansible/roles/forgejo/templates/custom/extra_links_footer.tmpl.j2:4-6` is plain HTML with hardcoded Swedish labels. Forgejo's `custom/templates/custom/*` hook fragments are not routed through the translation pipeline unless they ask for it explicitly. Nothing upstream is at fault — this is our fragment. **Fix** Forgejo exposes `ctx` (and therefore `ctx.Locale`) to every template as a per-request funcmap entry — `modules/templates/htmlrenderer.go` on the `v16.0.1` tag — including `custom/*` fragments, which are included with the full page context (`templates/base/footer_content.tmpl`: `{{template "custom/extra_links_footer" .}}`). So the fragment can branch on `{{ctx.Locale.Lang}}` (`sv-SE` / `en-US`) and emit the right label. Use English wording that matches the portal's own navigation: **Terms of Service** and **Privacy Policy**. Swedish output must stay exactly as it is today. Do **not** try to add custom translation keys under `custom/options/locale/`: locale files are read through a layered asset filesystem whose `ReadFile` returns the first matching layer and stops (`modules/options/base.go`, `modules/assetfs/layered.go`), so a custom `locale_en-US.ini` would replace the whole built-in English locale rather than extend it. **Done when** - The English UI shows English labels and the Swedish UI is unchanged, verified with the two `curl` commands above against production. - Previewed through `local/` (podman) before the production apply. Part of gitborg/gitborg-docs#70.
Logga in för att delta i denna konversation.
Ingen milstolpe
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-infra#333
Ingen beskrivning angiven.