- Set document language to full BCP-47 from domain config (e.g. pt-PT). - Extend ui-i18n with service errors, ad labels, ARIA landmarks, category meta fallback, and localized search upstream message. - Localize ArticleHeader (dates, reading time, breadcrumb); omit duplicate breadcrumb when institutional chrome already provides one. Docs: add docs/i18n.md strategy sketch; domains.md and deployment.md (BRIDGE_INTERNAL_URL) cross-links. Paperclip-Agent: ac1be104-8818-496a-80c5-fbc590a87855 Paperclip-Issue: 182b154e-5ad4-4965-9f30-50a66ef51ce0 Paperclip-Run: 6ce7746f-bfb6-4486-a1f5-aed26fe8e149 Made-with: Cursor
2.2 KiB
Internationalisation (i18n) — news-platform
Short sketch for BIT-739 and follow-on work.
Current model (minimal, non-breaking)
-
Per-domain locale — Each hostname loads
config/domains/<host>.json. Thelocalefield is a BCP 47 tag (e.g.pt-PTfor andebol.net,en-USfor localhost / English hubs). -
Document language —
frontend/src/layouts/Base.astrosets<html lang={config.locale}>so regional variants (e.g.pt-PT) are preserved for accessibility and SEO. -
Static UI strings —
frontend/src/lib/ui-i18n.tsmaps the primary language subtag (ptfrompt-PT) to a string table. English is the fallback for unknown languages. When a second Portuguese variant is needed (e.g.pt-BR), add an explicit branch ingetUiStringsrather than overloadingpt. -
Runtime formatting — Dates and relative times use
Intlviafrontend/src/lib/format.ts, passing the sameconfig.localeas the domain JSON. -
Auth chrome — Login/register labels for
auth_linksusefrontend/src/lib/auth-labels.ts(Portuguese whenlocalestarts withpt). -
Editorial content — Headlines, bodies, and categories come from WordPress / the bridge; they are not translated by the frontend. Domain config supplies section labels (
categories[].label) in the target language for each site.
Preparing for fuller multilang (not implemented yet)
Possible directions when the product requires multiple languages on the same hostname:
- Path prefix — e.g.
/en/...,/pt/..., with middleware choosinglocaleand canonical/hreflang rules. - Subdomains — e.g.
en.example.com/pt.example.com, each with its own domain JSON or a shared base pluslocaleoverride. - Cookie / Accept-Language — optional overlay once URLs and caching semantics are defined (CDN keys, bridge cache).
Until then, one locale per hostname keeps SSR caching and domain routing simple.
Operations alignment
Production Astro SSR should reach the bridge on an internal URL. Set BRIDGE_INTERNAL_URL on the frontend process so JSON bridge_endpoint loopback values in repo configs are overridden at runtime — see frontend/src/lib/domain.ts and docs/deployment.md.