WORK-502
ID:WORK-502Status:ready

i18n resolution foundation — locale config, LocaleContext, resolvers, fallback

The P0 foundation every other zone builds on: the locale/strings surface on ThemeConfig, the value types, the render-scoped LocaleContext slice, the resolver helpers, and the per-key fallback precedence. Nothing else in SPEC-035 can land without this.

Priority:highComplexity:moderateMilestone:v0.29.0Source:SPEC-035
claude/multi-language-support-spec-5zzt9q View source

Criteria completion

Criteria completion: 0 of 4 (0%) checked; tracking started on Jul 17, no incremental history yet0%25%50%75%100%Jul 17Jul 30

Tracking started Jul 17 — check back for trends.

Branches 2
claude/multi-language-support-spec-5zzt9q current ready
main doneclaude/milestone-v0-29-0-stzywk done
History 1
  1. d92ad0c
    Created (ready)by bjornolofandersson

Scope

  • Add locale?: string (BCP 47, default 'en') and strings?: Record<string, LocalizedValue> to ThemeConfig (packages/transform/src/types.ts).
  • Define LocalizedValue = string | PluralMap and PluralMap = Partial<Record<Intl.LDMLPluralRule, string>>.
  • Define LocaleContext { locale: string; strings: Record<string, LocalizedValue> } — the render-scoped slice threaded into consumers. It must never be module-global mutable state (SPEC-035 forward-compatibility constraint for future multi-locale builds).
  • Implement resolveLocaleString(ctx, key, fallback) and resolvePluralString(ctx, key, count, fallback) (via Intl.PluralRules, {n} interpolation).
  • Implement per-key fallback precedence (Decision D5): site strings → owning package's shipped locale bundle (with de-ATde region-strip) → English literal. First-match, per key — not a deep merge.
  • Unit tests for string/plural resolution, region-strip fallback, missing-key → English, and plural categories.

Acceptance Criteria

  • ThemeConfig.locale + strings and the LocalizedValue / PluralMap types exist and compile across dependents.
  • LocaleContext is defined; resolveLocaleString / resolvePluralString implemented with tests.
  • Per-key precedence + BCP-47 region-strip fallback implemented and tested.
  • Zero-config English is unchanged: with no locale / strings set, transform output is byte-identical to today.

References

  • SPEC-035 — Value Types, Locale Configuration, Resolution Mechanism, Resolution Precedence (D5), Decisions D2/D5/D6.