Files
karaoke-gen/frontend/components/instrumental-review/InstrumentalGuidancePanel.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

132 lines
4.2 KiB
TypeScript

"use client"
import { useState } from "react"
import { useTranslations } from 'next-intl'
import { ExternalLink, Lightbulb, X } from "lucide-react"
import type { BackingVocalAnalysis, AudibleSegment } from "@/lib/api"
interface InstrumentalGuidancePanelProps {
analysis: BackingVocalAnalysis
audibleSegments: AudibleSegment[]
}
export function InstrumentalGuidancePanel({
analysis,
audibleSegments,
}: InstrumentalGuidancePanelProps) {
const t = useTranslations('instrumentalReview.guidance')
const [guidanceDismissed, setGuidanceDismissed] = useState(() => {
if (typeof window === "undefined") return false
return localStorage.getItem("instrumentalReviewGuidanceDismissed") === "true"
})
const handleDismiss = () => {
setGuidanceDismissed(true)
if (typeof window !== "undefined") {
localStorage.setItem("instrumentalReviewGuidanceDismissed", "true")
}
}
const handleShowTips = () => {
setGuidanceDismissed(false)
if (typeof window !== "undefined") {
localStorage.removeItem("instrumentalReviewGuidanceDismissed")
}
}
const isCleanRecommended = analysis.recommended_selection === "clean"
const percentage = analysis.audible_percentage
const hasSegments = audibleSegments.length > 0
if (guidanceDismissed) {
return (
<div className="flex items-center gap-2 text-xs">
<button
className="text-amber-500 hover:text-amber-400 transition-colors"
onClick={handleShowTips}
>
{t('showTips')}
</button>
</div>
)
}
// Simple case: clean recommended with low backing vocals
if (isCleanRecommended && percentage < 10) {
return (
<div className="flex items-start gap-2 p-2.5 rounded-md bg-amber-500/10 border border-amber-500/20">
<Lightbulb className="h-4 w-4 text-amber-500 shrink-0 mt-0.5" />
<div className="text-xs text-muted-foreground flex-1 leading-relaxed space-y-1.5">
<p>
<strong>{t('chooseBackingTrack')}</strong>
</p>
<p>
{t('littleBackingVocals', { percentage: percentage.toFixed(0) })}
</p>
<p className="text-muted-foreground/70">
{t('hearDifference')}
</p>
<a
href="https://www.youtube.com/watch?v=-dI3r7qXo3A"
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-1 text-amber-500 hover:text-amber-400 transition-colors mt-1"
>
<ExternalLink className="h-3 w-3" />
{t('watchFullTutorial')}
</a>
</div>
<button
className="text-muted-foreground hover:text-foreground transition-colors shrink-0"
onClick={handleDismiss}
aria-label={t('dismissTip')}
>
<X className="h-3.5 w-3.5" />
</button>
</div>
)
}
// Complex case: backing vocals present, needs review
return (
<div className="flex items-start gap-2 p-2.5 rounded-md bg-amber-500/10 border border-amber-500/20">
<Lightbulb className="h-4 w-4 text-amber-500 shrink-0 mt-0.5" />
<div className="text-xs text-muted-foreground flex-1 leading-relaxed space-y-1.5">
<p>
<strong>{t('chooseBackingTrack')}</strong>
</p>
<p>
{t('backingVocalsExplanation')}
</p>
<div className="space-y-1 pl-2 border-l-2 border-amber-500/30">
<p>
{t('step1', { segments: hasSegments ? ` (${audibleSegments.length} detected)` : '' })}
</p>
<p>
{t('step2')}
</p>
<p>
{t('step3')}
</p>
</div>
<a
href="https://www.youtube.com/watch?v=-dI3r7qXo3A"
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-1 text-amber-500 hover:text-amber-400 transition-colors mt-1"
>
<ExternalLink className="h-3 w-3" />
{t('watchFullTutorial')}
</a>
</div>
<button
className="text-muted-foreground hover:text-foreground transition-colors shrink-0"
onClick={handleDismiss}
aria-label={t('dismissTip')}
>
<X className="h-3.5 w-3.5" />
</button>
</div>
)
}