Files
karaoke-gen/frontend/components/instrumental-review/StemComparison.tsx
T
Andrew Beveridge ☄️andClaude Opus 4.6 8c1dfe5460 feat(i18n): Phase 3 frontend — next-intl infrastructure + 1062 strings (en/es/de) (#656)
@coderabbitai ignore

## Summary
- Phase 3 of the i18n multilingual initiative — makes the karaoke-gen
frontend fully multilingual (English, Spanish, German)
- Installs `next-intl` with `[locale]` path-based routing,
LanguageSwitcher, and `Accept-Language` API header
- Extracts **1,062 strings** from ~70 components into `messages/en.json`
across 31 namespaces
- Wires `useTranslations()` into all user-facing components (landing,
dashboard, auth, job flow, lyrics review, instrumental review, audio
editor, etc.)
- Admin pages (`/admin/*`) stay outside locale routing — intentionally
excluded from i18n scope
- Static export generates `/en/`, `/es/`, `/de/` directories (45 total
pages) for Cloudflare Pages
- `es.json`/`de.json` are English placeholders — translation via Gemini
pipeline pending
- Translation pipeline (`scripts/translate.py`) and glossary (55
karaoke-specific terms) included

## Key architecture decisions
- Root layout keeps ThemeProvider/TenantProvider (needed by admin pages
outside `[locale]`)
- Only NextIntlClientProvider added to `[locale]/layout.tsx`
- `job-status.ts` labels converted to translation keys; consumers
translate via `useTranslations('jobStatus')`
- Jest mock loads actual `en.json` so existing tests validate i18n
wiring without assertion changes

## Test plan
- [x] All 707 frontend tests pass (39 suites)
- [x] Static build generates all 45 pages across 3 locales
- [x] Admin pages render at `/admin/` without locale prefix
- [x] CodeRabbit review: 4 issues fixed, 7 pre-existing noted
- [ ] Post-deploy: verify `/en/` landing page renders correctly
- [ ] Post-deploy: verify LanguageSwitcher redirects to `/es/` and
`/de/`
- [ ] Post-deploy: verify `/admin/` still works without locale context

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 21:50:53 -04:00

77 lines
2.3 KiB
TypeScript

"use client"
import { useTranslations } from 'next-intl'
import { cn } from "@/lib/utils"
import { Loader2 } from "lucide-react"
export type AudioType = "original" | "backing" | "clean" | "with_backing" | "custom" | "uploaded"
interface StemComparisonProps {
activeAudio: AudioType
onAudioChange: (type: AudioType) => void
hasOriginal: boolean
hasWithBacking: boolean
hasCustom: boolean
hasUploaded: boolean
uploadedFilename?: string
isLoading?: boolean
}
interface AudioOption {
type: AudioType
label: string
available: boolean
title?: string
}
export function StemComparison({
activeAudio,
onAudioChange,
hasOriginal,
hasWithBacking,
hasCustom,
hasUploaded,
uploadedFilename,
isLoading = false,
}: StemComparisonProps) {
const t = useTranslations('instrumentalReview.stemComparison')
const options: AudioOption[] = [
{ type: "original", label: t('original'), available: hasOriginal },
{ type: "backing", label: t('backingVocalsOnly'), available: true },
{ type: "clean", label: t('pureInstrumental'), available: true },
{ type: "with_backing", label: t('instrumentalPlusBacking'), available: hasWithBacking },
{ type: "custom", label: t('custom'), available: hasCustom },
{ type: "uploaded", label: t('uploaded'), available: hasUploaded, title: uploadedFilename },
]
const availableOptions = options.filter((opt) => opt.available)
return (
<div className="flex flex-wrap gap-1 bg-background rounded-md p-0.5">
{availableOptions.map((option) => {
const isActive = activeAudio === option.type
const showSpinner = isActive && isLoading
return (
<button
key={option.type}
type="button"
onClick={() => onAudioChange(option.type)}
disabled={isLoading}
title={option.title}
className={cn(
"px-2.5 py-1.5 rounded text-xs font-medium transition-all flex items-center gap-1.5",
"text-muted-foreground hover:text-foreground",
isActive && "bg-primary text-primary-foreground",
isLoading && !isActive && "opacity-50 cursor-not-allowed"
)}
>
{showSpinner && <Loader2 className="w-3 h-3 animate-spin" />}
{option.label}
</button>
)
})}
</div>
)
}