Charlie Roffe

Principal Architect & Engineering Director · Cloud & AI

Madrid, Spain · LinkedIn · GitHub

ADR-014: Bilingual Localization Strategy (EN/ES)

Context

The portfolio targets two audiences at once: the international (English-speaking) market and the Spanish market where the author and infrastructure are based (Madrid). Every piece of content — navigation, project copy, blog posts, and the full ADR library — must exist in both languages, switch instantly without reloads, carry shareable locale URLs, and add zero infrastructure.

Decision

Implement localization as a typed, in-memory bilingual content model rather than adopting an i18n framework.

Every piece of content in src/data/ (portfolio, blog, ADRs, architecture details, models) is an { en, es } pair enforced by the types in src/types.ts — a missing translation is a compile error, not a runtime fallback. Short UI strings are the exception: t(key) falls back to the key itself at runtime. A single React LanguageContext holds the active language; switching is an in-memory state change that re-renders the whole UI instantly (ADR-003). Spanish routes carry an /es prefix while English routes have none (src/routes.ts), so links are locale-stable and independently indexable. The ADRs themselves are first-class bilingual content rendered from these structured entries.

Amended 2026-11-20 (ADR-045): the static { en, es } model now acts as Tier 0 of a hybrid three-tier translation system. Visitors selecting one of ~180 additional languages receive on-demand translation over closed-world content chunks (UI_TRANSLATIONS in src/data/translationChunks.ts, pageCopy.ts, demoCopy.ts, and lazy section chunks in translationChunksLazy.ts) via Tier 1 on-device Browser Translator API (self.Translator) or Tier 2 server-cached Gemini Flash-Lite fallback (POST /api/ai/translate). Canonical URLs and search indexing remain strictly English (/) and Spanish (/es).

Consequences

Benefits:
* Instant bilingual UX — zero network cost, zero content flash on switching.
* Parity enforced by the compiler: untranslated content cannot build.
* No framework weight: no i18next/ICU runtime, no async catalogs — for exactly two locales, typed objects are simpler and smaller.
* SEO and shareability via a distinct URL per language.

Trade-offs:
* Translations are hand-maintained; every content change is authored twice.
* The bundle ships both languages — a few tens of KB gzipped, preferred over per-locale code splitting complexity.

Alternatives considered

1. i18next / react-intl: Rejected — catalog loading, pluralization engines, and extraction tooling solve problems a two-locale single-author site does not have, at real bundle cost.
2. Separate per-locale builds: Rejected — doubles hosting artifacts and CI time, and breaks the instant in-page language toggle.
3. Machine translation at runtime: Rejected — unacceptable quality for professional copy plus a paid external dependency in the request path.

Architecture Decision Records