Files
evig/src
Mao NakamotoandClaude Opus 4.7 c6b084792d feat(i18n): DB-content translations for workshops + project_needs (no more German bleed on /ru, /fr, /es, /it, /ja, /ko)
Until now, the /workshops list and the "what we need" cards on
/projects/upcycling showed German DB content (workshop titles, durations,
levels, categories, need titles + descriptions) regardless of locale —
because those fields were single TEXT columns with one German value.

Migration 088 adds sibling JSONB columns `<field>_i18n` of shape
{ en, fr, es, it, ja, ko, ru → translated string } on:
  - workshops:     title, description, short_description, duration, level, category
  - project_needs: title, description, target_unit
Each column nullable, no default — empty = the helper falls back to the
canonical DE column. Idempotent (ADD COLUMN IF NOT EXISTS), already
applied to Neon production.

New helper src/lib/i18n/db-content.ts → `pickI18n(canonical, jsonb, locale)`
encapsulates the picking strategy in ONE place (SSOT). `de` → canonical.
Other locales → JSONB[locale] if present, else canonical. NULL safety
built in so callers pass raw rows.

Two consumers updated at the data boundary so the client never touches
JSONB:
- src/app/[locale]/workshops/page.tsx — accepts params.locale, selects
  all the *_i18n columns, runs each row through pickI18n before passing
  to WorkshopBrowseClient
- src/app/api/projects/[slug]/needs/route.ts — resolves visitor locale
  from URL prefix or NEXT_LOCALE cookie, applies pickI18n on the way
  out, same shape as before

Seed data:
- scripts/db/seeds/001_workshops_and_needs_i18n.sql — hand-translates
  all 6 active workshops (Linux/Open-Source/Computerreparatur/
  Bitcoin/AI/Kreatives Programmieren) and all 7 open project_needs
  (CE engineer, electronics, sheltered workshop, facility mgmt, 24"+
  monitors, LCA funding, per-model docs) into 7 locales. Applied
  to production immediately.

Result: /ru/workshops now reads "Семинар по Linux · 2 дня · От начинающего
до продвинутого", /fr/workshops reads "Atelier Linux · 2 jours · Débutant
à avancé", etc. /ru/projects/upcycling needs cards read in Russian.

CI gate: any future locale missing here means the visitor sees DE — not
a leak (the schema permits it intentionally as a fallback). New rows
inserted via admin UI need translations entered alongside; future admin-
UI work can surface the seven locale fields per text column. Out of scope.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-09 21:29:42 +02:00
..