mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-20 13:07:57 +09:00
@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>
147 lines
4.6 KiB
TypeScript
147 lines
4.6 KiB
TypeScript
"use client"
|
|
|
|
import { useTranslations } from 'next-intl'
|
|
import { Button } from "@/components/ui/button"
|
|
import { X } from "lucide-react"
|
|
import type { MuteRegion, AudibleSegment } from "@/lib/api"
|
|
|
|
interface MuteRegionEditorProps {
|
|
regions: MuteRegion[]
|
|
audibleSegments: AudibleSegment[]
|
|
hasCustom: boolean
|
|
isCreatingCustom: boolean
|
|
onRemoveRegion: (index: number) => void
|
|
onClearAll: () => void
|
|
onCreateCustom: () => void
|
|
onSeekTo: (time: number) => void
|
|
onAddSegment: (index: number) => void
|
|
onHoverRegion?: (index: number | null) => void
|
|
onHoverSegment?: (index: number | null) => void
|
|
}
|
|
|
|
function formatTime(seconds: number): string {
|
|
if (!Number.isFinite(seconds)) return "0:00"
|
|
const mins = Math.floor(seconds / 60)
|
|
const secs = Math.floor(seconds % 60)
|
|
return `${mins}:${secs.toString().padStart(2, "0")}`
|
|
}
|
|
|
|
export function MuteRegionEditor({
|
|
regions,
|
|
audibleSegments,
|
|
hasCustom,
|
|
isCreatingCustom,
|
|
onRemoveRegion,
|
|
onClearAll,
|
|
onCreateCustom,
|
|
onSeekTo,
|
|
onAddSegment,
|
|
onHoverRegion,
|
|
onHoverSegment,
|
|
}: MuteRegionEditorProps) {
|
|
const t = useTranslations('instrumentalReview.muteRegion')
|
|
const hasRegions = regions.length > 0
|
|
const hasSegments = audibleSegments.length > 0
|
|
|
|
return (
|
|
<div className="bg-card border border-border rounded-lg p-3 flex flex-col gap-2 max-h-[180px] lg:max-h-[140px]">
|
|
{/* Header */}
|
|
<div className="flex items-center justify-between">
|
|
<span className="text-sm font-semibold">
|
|
{hasRegions ? t('titleWithCount', { count: regions.length }) : t('title')}
|
|
</span>
|
|
{hasRegions && (
|
|
<div className="flex gap-1.5">
|
|
<Button
|
|
variant="secondary"
|
|
size="sm"
|
|
onClick={onClearAll}
|
|
className="h-7 text-xs"
|
|
>
|
|
{t('clear')}
|
|
</Button>
|
|
{!hasCustom && (
|
|
<Button
|
|
size="sm"
|
|
onClick={onCreateCustom}
|
|
disabled={isCreatingCustom}
|
|
className="h-7 text-xs"
|
|
>
|
|
{isCreatingCustom ? t('creating') : t('createCustom')}
|
|
</Button>
|
|
)}
|
|
</div>
|
|
)}
|
|
</div>
|
|
|
|
{/* Region tags */}
|
|
{hasRegions ? (
|
|
<div className="flex flex-wrap gap-1.5 overflow-y-auto flex-1">
|
|
{regions.map((region, index) => (
|
|
<div
|
|
key={index}
|
|
className="inline-flex items-center gap-1 px-2 py-1 bg-secondary rounded text-xs"
|
|
onMouseEnter={() => onHoverRegion?.(index)}
|
|
onMouseLeave={() => onHoverRegion?.(null)}
|
|
>
|
|
<button
|
|
type="button"
|
|
onClick={() => onSeekTo(region.start_seconds)}
|
|
className="hover:text-primary cursor-pointer"
|
|
>
|
|
{formatTime(region.start_seconds)} - {formatTime(region.end_seconds)}
|
|
</button>
|
|
<button
|
|
type="button"
|
|
onClick={() => onRemoveRegion(index)}
|
|
className="text-muted-foreground hover:text-destructive ml-1"
|
|
>
|
|
<X className="w-3 h-3" />
|
|
</button>
|
|
</div>
|
|
))}
|
|
</div>
|
|
) : (
|
|
<div className="text-xs text-muted-foreground space-y-1">
|
|
{hasSegments ? (
|
|
<>
|
|
<p>
|
|
{t('explanation')}
|
|
</p>
|
|
<p className="text-muted-foreground/70">
|
|
{t('clickSegment')}
|
|
</p>
|
|
</>
|
|
) : (
|
|
<p>{t('noBackingDetected')}</p>
|
|
)}
|
|
</div>
|
|
)}
|
|
|
|
{/* Quick segment buttons */}
|
|
{hasSegments && (
|
|
<div className="flex flex-wrap gap-1">
|
|
{audibleSegments.slice(0, 8).map((segment, index) => (
|
|
<button
|
|
key={index}
|
|
type="button"
|
|
onClick={() => onAddSegment(index)}
|
|
onMouseEnter={() => onHoverSegment?.(index)}
|
|
onMouseLeave={() => onHoverSegment?.(null)}
|
|
title={t('addToMuteRegions')}
|
|
className="px-1.5 py-0.5 bg-background border border-border rounded text-[10px] text-muted-foreground hover:border-primary hover:text-primary transition-colors"
|
|
>
|
|
{formatTime(segment.start_seconds)} - {formatTime(segment.end_seconds)}
|
|
</button>
|
|
))}
|
|
{audibleSegments.length > 8 && (
|
|
<span className="text-xs text-muted-foreground px-1 py-0.5">
|
|
+{audibleSegments.length - 8} more
|
|
</span>
|
|
)}
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|