Skip to content

i18n sync pipeline: backend YAML -> bundled frontend JSON (pattern 05) - #33

Merged
astrapi69 merged 1 commit into
mainfrom
feature/i18n-sync
Jun 29, 2026
Merged

astrapi69 merged 1 commit into
mainfrom
feature/i18n-sync

Conversation

@astrapi69

Copy link
Copy Markdown
Owner

Closes #32

Implements pattern 05 (i18n sync) — the last documented pattern that was still "Partial". Backend YAML is the single source of truth; the frontend now consumes a bundled JSON mirror, so translations need no backend roundtrip and work in a static/offline build.

  • scripts/sync_i18n.py mirrors backend/config/i18n/*.yaml -> frontend/src/data/i18n/*.json (8 catalogs: de/el/en/es/fr/ja/pt/tr). make sync-i18n + make sync-i18n-check (drift gate).
  • useI18n rewired to load the bundled JSON via import.meta.glob (default de eager for instant first paint, the others lazy chunks on language switch) instead of api.i18n.get(lang). t() and the public hook API are unchanged, so no component changes.
  • i18n-bundle.test.ts pins that the bundle is populated (a stale/empty bundle would make every t() fall back to its key).
  • The generated JSON is committed (build/checkout works without running sync); sync-i18n-check keeps it honest.

Green

tsc --noEmit clean. make sync-i18n-check in sync. ESLint clean. Vitest 1201 passed. Build OK (precache 37->44: the bundled language chunks). complexity/file-size/dir gates still green.

Note

The backend /i18n/{lang} endpoint + api.i18n.get client method are left in place (harmless; a dual-mode app could still use them) — just no longer the frontend's source for strings.

Implements pattern 05:
- scripts/sync_i18n.py mirrors backend/config/i18n/*.yaml to
  frontend/src/data/i18n/*.json (8 catalogs); make sync-i18n +
  sync-i18n-check (drift gate).
- useI18n loads the bundled JSON via import.meta.glob (default 'de' eager,
  the rest lazy chunks) instead of fetching GET /i18n/{lang}, so i18n needs
  no backend roundtrip and works in a static/offline build. t() unchanged.
- i18n-bundle.test.ts pins that the bundle is populated.

tsc clean; eslint clean; Vitest 1201 passed; build OK (lang chunks bundled);
sync-i18n-check in sync. Closes #32
@astrapi69
astrapi69 merged commit c3c226d into main Jun 29, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

i18n sync pipeline: backend YAML -> bundled frontend JSON (pattern 05)

2 participants