Files
news-platform/docs/i18n.md
T
Artur Moreira b629f6c6aa feat(frontend): PT shell i18n, html lang pt-PT, i18n docs (BIT-739)
- 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
2026-04-02 20:06:48 +00:00

32 lines
2.2 KiB
Markdown

# Internationalisation (i18n) — news-platform
Short sketch for **BIT-739** and follow-on work.
## Current model (minimal, non-breaking)
1. **Per-domain locale** — Each hostname loads `config/domains/<host>.json`. The `locale` field is a BCP 47 tag (e.g. `pt-PT` for andebol.net, `en-US` for localhost / English hubs).
2. **Document language** — `frontend/src/layouts/Base.astro` sets `<html lang={config.locale}>` so regional variants (e.g. `pt-PT`) are preserved for accessibility and SEO.
3. **Static UI strings** — `frontend/src/lib/ui-i18n.ts` maps the **primary language subtag** (`pt` from `pt-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 in `getUiStrings` rather than overloading `pt`.
4. **Runtime formatting** — Dates and relative times use `Intl` via `frontend/src/lib/format.ts`, passing the same `config.locale` as the domain JSON.
5. **Auth chrome** — Login/register labels for `auth_links` use `frontend/src/lib/auth-labels.ts` (Portuguese when `locale` starts with `pt`).
6. **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 choosing `locale` and canonical/hreflang rules.
- **Subdomains** — e.g. `en.example.com` / `pt.example.com`, each with its own domain JSON or a shared base plus `locale` override.
- **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`.