Skip to content

i18n: Phase 5 — aliases for IT-slug back-compat on translated EN pages#13

Merged
abonforti merged 6 commits into
azzurra:masterfrom
vjt:i18n/aliases
May 10, 2026
Merged

i18n: Phase 5 — aliases for IT-slug back-compat on translated EN pages#13
abonforti merged 6 commits into
azzurra:masterfrom
vjt:i18n/aliases

Conversation

@vjt
Copy link
Copy Markdown
Contributor

@vjt vjt commented May 10, 2026

Summary

Adds Hugo aliases: on the 11 EN pages where the translated slug differs from the original IT filename, so any external link to /en/<it-stem>/ redirects to the canonical /en/<en-slug>/ via meta-refresh.

This closes the i18n series: scaffold (PR #11) + content translation (PR #12) + slug back-compat (this PR).

Files touched

5 root pages and 6 news posts. Pages with unchanged slug (faq, kline, network, gamebot, nickserv-resetpass) need no alias.

translated EN page alias from
/en/history/ /en/storia/
/en/connect/ /en/come-connettersi/
/en/contact/ /en/contatti/
/en/rules/ /en/regolamento/
/en/services/ /en/servizi/
/en/news/new-website/ /en/news/nuovo-sito/
/en/news/new-website-2008/ /en/news/nuovo-sito-2008/
/en/news/new-servers-2026/ /en/news/nuovi-server-2026/
/en/news/reorganisation-2020/ /en/news/riorganizzazione-2020/
/en/news/webchat-back-online/ /en/news/webchat-operativa/
/en/news/azzurra-reborn-as-azzurra-chat/ /en/news/azzurra-rinasce-come-azzurra-chat/

Build verification

hugomods/hugo:exts-0.145.0: IT 42 + EN 41 pages, EN aliases jumped from 11 → 22 (+11 new), zero warnings.

Spot-checked rendered HTML for storia / come-connettersi / nuovi-server-2026 — each emits the expected <meta http-equiv=refresh content="0; url=…"> to its canonical EN slug, with noindex to avoid SEO duplication.

Stacking

Base = master, but the branch sits on top of i18n/content-translations (PR #12). Once PR #11 and PR #12 are merged, the diff here naturally shrinks to just the 11 frontmatter additions.

Test plan

  • Hugo build green on hugomods/hugo:exts-0.145.0 (42 IT + 41 EN, +11 EN aliases)
  • Manual inspection of generated public/en/storia/index.html, public/en/come-connettersi/index.html, public/en/news/nuovi-server-2026/index.html — meta-refresh targets correct
  • Reviewer to confirm slug→alias mapping is sensible (open question: should /en/news/nuovo-sito/ alias the 2008 or the 2026 IT slug? Currently it goes by exact filename, so /en/news/nuovo-sito/ → new-website (2026) and /en/news/nuovo-sito-2008/ → new-website-2008)

vjt added 6 commits May 10, 2026 21:07
Phase 1 (config split):
- hugo.toml restructured into [languages.it] (default, served at /) and
  [languages.en] (served at /en/)
- defaultContentLanguageMissing left at "fallback" implicitly so missing
  EN pages render the IT version instead of 404
- Stats labels and menu names translated per-language

Phase 2 (theme i18n extraction):
- themes/azzurra/i18n/{it,en}.toml with ~22 keys
- All hardcoded UI strings in baseof / index / list / single / info
  shortcode replaced with {{ i18n "key" }}
- Internal links use relLangURL so /en/ pages keep their language prefix

Phase 3 (date format):
- dateFormat key per language, rendered via time.Format which honors the
  page's languageCode → "10 maggio 2026" on /it, "May 10, 2026" on /en

Sample translation:
- content/news/gamebot.en.md as proof-of-concept; same slug across langs

Parity gate:
- .githooks/pre-commit blocks any commit that adds/modifies content/*.md
  without a sibling .en.md (excludes _index.md and *.en.md itself)
- .github/workflows/i18n-parity.yml mirrors the check server-side as the
  non-bypassable gate; --no-verify only skips the local fast-iteration hook

Smoke build (hugomods/hugo:exts-0.145.0): clean, IT+EN sites render,
58 pages total, zero i18n warnings.
Hypnotize requested:
1. Parity gate must work both ways: an EN content file without an IT
   counterpart should also block. Refactored .githooks/pre-commit and
   .github/workflows/i18n-parity.yml to enforce sibling existence in
   either direction.
2. Add vjt (vjt@azzurra.chat) to the staff mailto block in baseof.

Bonus: workflow trigger branch fixed master (was main).

Smoke build still green: IT 42 + EN 16 pages, zero warnings.
The original full-tree scan blocked PR#11 because the scaffold ships only
one sample .en.md while the rest of content/ is still IT-only — exactly
the state PR#12 is meant to fix. Bidirectional enforcement still applies,
just only to files touched in the current PR (mirrors the delta-based
.githooks/pre-commit hook). The incremental scaffold → content → aliases
landing pattern now works without each PR having to ship a complete set.
Replaces the filename-suffix layout (content/foo.md + content/foo.en.md
with slug overrides) with explicit directory split. Translated pages now
live under their own language tree with English filenames matching the
public URL, so reviewers see content/en/news/gamebot.md rather than
content/news/gamebot.en.md with slug=gamebot — the github file URL no
longer contradicts the language of the content.

Pairing across languages is declared via the translationKey frontmatter
field rather than inferred from a shared filename stem. The scaffold
sample (news/gamebot) ships paired with translationKey: news-gamebot on
both sides; PR#12 adds the matching keys on the other pages as their EN
counterparts land.

hugo.toml: per-language contentDir lets Hugo route each tree
independently. defaultContentLanguage=it keeps IT URLs at the root
(no /it/ prefix), EN remains at /en/.

Parity gate: the pre-commit hook and the GitHub Action workflow both
switch from filename-stem matching to translationKey matching, using
identical extraction logic. Pages without a translationKey are treated
as not-yet-paired (free pass) — the gate enforces well-formed pairs, it
does not force every page to be translated. Only declared keys must
resolve in the other language tree.

Smoke build: hugo 0.145.0+extended → IT 42 + EN 16 pages, zero warnings,
gamebot sample renders at /en/news/gamebot/ (filename = slug).
Adds the English siblings under content/en/ (matching the dir-split
layout from the previous commit), with translationKey wiring to the
Italian originals under content/it/. Eight root pages (connect, contact,
faq, history, kline, network, rules, services) plus seven news posts
(azzurra-reborn-as-azzurra-chat, new-servers-2026, new-website-2008,
new-website, nickserv-resetpass, reorganisation-2020, webchat-back-online).

URLs follow the language tree natively now: IT at /<it-slug>/ and EN at
/en/<en-slug>/, no slug overrides needed in frontmatter.

Italian sources gain a translationKey field but are otherwise unchanged.
Adds Hugo aliases on the 11 EN pages where the translated slug differs
from the Italian source filename. External links to /en/<it-stem>/ now
redirect to the canonical /en/<en-slug>/ via meta-refresh, generated by
Hugo from the `aliases:` frontmatter list.

Root pages (5):
  /en/storia/           -> /en/history/
  /en/come-connettersi/ -> /en/connect/
  /en/contatti/         -> /en/contact/
  /en/regolamento/      -> /en/rules/
  /en/servizi/          -> /en/services/

News (6):
  /en/news/nuovo-sito/                      -> /en/news/new-website/
  /en/news/nuovo-sito-2008/                 -> /en/news/new-website-2008/
  /en/news/nuovi-server-2026/               -> /en/news/new-servers-2026/
  /en/news/riorganizzazione-2020/           -> /en/news/reorganisation-2020/
  /en/news/webchat-operativa/               -> /en/news/webchat-back-online/
  /en/news/azzurra-rinasce-come-azzurra-chat/ -> /en/news/azzurra-reborn-as-azzurra-chat/

Pages whose slug already matches in both languages (faq, kline, network,
gamebot, nickserv-resetpass) need no alias. Stacked on PR#12 (Phase 4).
@abonforti abonforti marked this pull request as ready for review May 10, 2026 22:01
@Essency Essency self-requested a review May 10, 2026 22:09
@abonforti abonforti merged commit d7a174b into azzurra:master May 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants