diff --git a/.next/trace b/.next/trace new file mode 100644 index 00000000..4c674995 --- /dev/null +++ b/.next/trace @@ -0,0 +1 @@ +[{"name":"generate-buildid","duration":272,"timestamp":244518298649,"id":4,"parentId":1,"tags":{},"startTime":1775262331361,"traceId":"b3ef0d179e8acedf"},{"name":"load-custom-routes","duration":314,"timestamp":244518299029,"id":5,"parentId":1,"tags":{},"startTime":1775262331361,"traceId":"b3ef0d179e8acedf"},{"name":"create-dist-dir","duration":333,"timestamp":244518299363,"id":6,"parentId":1,"tags":{},"startTime":1775262331362,"traceId":"b3ef0d179e8acedf"},{"name":"clean","duration":358,"timestamp":244518300558,"id":7,"parentId":1,"tags":{},"startTime":1775262331363,"traceId":"b3ef0d179e8acedf"},{"name":"next-build","duration":1670851,"timestamp":244516630180,"id":1,"tags":{"buildMode":"default","version":"16.2.2","bundler":"turbopack","failed":true},"startTime":1775262329693,"traceId":"b3ef0d179e8acedf"}] diff --git a/.next/trace-build b/.next/trace-build new file mode 100644 index 00000000..a50695b1 --- /dev/null +++ b/.next/trace-build @@ -0,0 +1 @@ +[{"name":"next-build","duration":1670851,"timestamp":244516630180,"id":1,"tags":{"buildMode":"default","version":"16.2.2","bundler":"turbopack","failed":true},"startTime":1775262329693,"traceId":"b3ef0d179e8acedf"}] diff --git a/docs/LESSONS-LEARNED.md b/docs/LESSONS-LEARNED.md index 07c19aab..00040538 100644 --- a/docs/LESSONS-LEARNED.md +++ b/docs/LESSONS-LEARNED.md @@ -1070,3 +1070,19 @@ For this bug, the missing test was: "does `transcribe_lyrics()` return `lyrics_d **Fix:** (1) Root cause: Don't write `corrections_updated.json` unless the payload actually contains a `"corrections"` key. (2) Defensive: Both GCE and Cloud Run workers validate the downloaded JSON has the expected structure before processing, falling back to base result if not. **Key insight:** When a file's existence is used as a boolean signal ("corrections were updated"), never write it with empty/invalid content. The existence check and content processing must agree on what constitutes a valid file. Apply defense in depth: fix the writer AND validate in readers. + +### i18n: Keep Providers in Root Layout When Admin Pages Exist (Apr 2026) + +**Problem:** The Phase 1/2 i18n pattern (public-website, karaoke-decide) stripped the root `app/layout.tsx` bare and moved all providers into `app/[locale]/layout.tsx`. This doesn't work for karaoke-gen because admin pages at `app/admin/` sit outside the `[locale]` route segment and need ThemeProvider/TenantProvider. + +**Fix:** Keep shared providers (ThemeProvider, TenantProvider, ImpersonationBannerWrapper, ServiceWorkerRegistration, GoogleAnalytics) in root layout. Only add NextIntlClientProvider to `[locale]/layout.tsx`. Admin pages inherit root providers without locale context. + +**Key insight:** When adding `[locale]` routing to a project with routes that should NOT be locale-prefixed (admin, API, etc.), don't blindly follow the "strip root layout" pattern. Keep shared providers in root so all route segments can access them. + +### i18n: Mock next-intl in Jest by Loading en.json (Apr 2026) + +**Problem:** Adding `useTranslations` to components caused 27 test suites to fail — Jest can't handle ESM exports from `next-intl`, and even after fixing that, tests that assert on English text (e.g., `screen.getByText("Review Lyrics")`) fail because the mock returns translation keys instead of English strings. + +**Fix:** Mock `next-intl` in `jest.setup.js` with a function that loads the actual `messages/en.json` and resolves dotted key paths to real English strings. Tests see the same text users see, no test assertions need updating. The mock supports interpolation (`{count}`, ICU plurals). + +**Key insight:** For i18n refactors, make the test mock return real translations, not keys. This lets existing tests validate that the i18n wiring produces correct output without changing every assertion. The mock is ~20 lines and eliminates hundreds of test updates. diff --git a/docs/README.md b/docs/README.md index e2d81d81..9005f139 100644 --- a/docs/README.md +++ b/docs/README.md @@ -36,6 +36,7 @@ | **Community version detection** | Working (via karaokenerds.com) | | **Review session backup/restore** | Working (auto-save + restore UI) | | **Review reminder & auto-expiry** | Working (24h reminder, 48h cancel + refund) | +| **i18n / Multilingual (frontend)** | Working (next-intl, en/es/de, 1062 strings, [locale] routing) | ## Known Issues diff --git a/docs/archive/2026-04-03-i18n-phase3-plan.md b/docs/archive/2026-04-03-i18n-phase3-plan.md new file mode 100644 index 00000000..63a27082 --- /dev/null +++ b/docs/archive/2026-04-03-i18n-phase3-plan.md @@ -0,0 +1,215 @@ +# Plan: Karaoke-Gen i18n Multilingual (Phase 3) + +**Created:** 2026-04-03 +**Branch:** `feat/sess-20260403-1115-i18n-multilingual` +**Worktree:** `/Users/andrew/Projects/nomadkaraoke/karaoke-gen-i18n-multilingual` +**Status:** Draft + +## Context + +This is Phase 3 of the i18n multilingual initiative. Phases 1+2 shipped successfully for public-website (205 strings) and karaoke-decide (811 frontend + 47 backend strings). The patterns are proven — we're replicating them in karaoke-gen, the most complex project (many frontend surfaces + multi-layered backend). + +## Scope Decisions + +| Decision | Choice | Rationale | +|----------|--------|-----------| +| Admin pages (`/admin/*`) | **Exclude** from i18n | Internal-only, ~30% more strings for zero user impact. Can add later. | +| Tenant default locale | **Out of scope** | Orthogonal to user locale; user's localStorage/browser detection suffices | +| Hash routing compatibility | **No conflict** | Hash (`#/jobId/review`) is client-side only, preserved across locale changes | +| Providers in root layout | **Keep in root** | Unlike Phase 1/2, karaoke-gen has admin pages outside `[locale]` that need ThemeProvider/TenantProvider. Only NextIntlClientProvider moves to `[locale]/layout.tsx`. | + +## Architecture: Frontend Key Difference from Phase 1/2 + +karaoke-gen has admin pages at `app/admin/` that must NOT be under `[locale]` routing. So: + +- **Root `app/layout.tsx`**: Keeps ``, ``, ThemeProvider, TenantProvider, ImpersonationBannerWrapper, ServiceWorkerRegistration, GoogleAnalytics. Remove hardcoded `lang="en"`. +- **`app/[locale]/layout.tsx`**: Adds NextIntlClientProvider + inline `