Sync localized blog title and meta when English source changes

Merged
RI
3d ago
+241-24

Problem

Localized blog pages can keep a stale <title> and meta description after the English post is retitled. Example checked on 2026-10-19:

Root cause

The translation worker already detects English HTML changes via X-Capgo-Translation-Source-Hash and refreshes executable scripts on cached STALE/HIT responses, but it did not refresh translatable head metadata (title, description, Open Graph, Twitter). Cached localized HTML could therefore keep outdated titles and descriptions until a full background retranslation finished (or indefinitely if the queue lagged).

Fix

On cached localized responses where the stored source hash differs from the current English HTML hash, the worker now:

  1. Keeps the existing executable script sync.
  2. Re-translates translatable head fields from the current English source and patches them into the cached HTML (X-Capgo-Translation-Meta: synced).
  3. Still enqueues full page retranslation via the existing stale/source-check pipeline.

Verification

  • Extended apps/translation-worker/scripts/verify-parser.ts STALE blog coverage for meta sync.
  • Added bun run check:blog-hash-drift in apps/translation-worker to list localized blog URLs whose stored translation hash does not match the live English HTML.

Affected URLs (sample)

Production scan on 2026-10-19:

After this worker deploys, the first request to each drifted URL should serve updated translated title and description immediately, while background jobs refresh the full cached page.

Remaining action after merge

  1. Merge and let Deploy Translation Worker run on main (or run that workflow manually) so production picks up the worker change.
  2. No manual KV/R2 purge is required for meta: response-path sync runs on the next localized blog request when the stored source hash differs from current English HTML.
  3. Optional: run bun run check:blog-hash-drift after deploy to confirm stored hashes converge as pages are visited and background retranslations complete.
Open in Web Open in Cursor 

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • New Features
    • When an English blog page changes, its localized versions now update translated page titles and supported SEO metadata alongside existing content. Repeated source text uses consistent translations, and short SEO descriptions are expanded when metadata changes.
  • Bug Fixes
    • Localized blog pages are less likely to display outdated titles or descriptions after their English source is updated.