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>
104 lines
2.7 KiB
TypeScript
104 lines
2.7 KiB
TypeScript
'use client'
|
|
|
|
import { useTranslations } from 'next-intl'
|
|
import { useState } from 'react'
|
|
import { Button } from '@/components/ui/button'
|
|
import { Input } from '@/components/ui/input'
|
|
import { Textarea } from '@/components/ui/textarea'
|
|
import { Label } from '@/components/ui/label'
|
|
import { Loader2 } from 'lucide-react'
|
|
|
|
interface PasteLyricsTabProps {
|
|
onAdd: (source: string, lyrics: string) => Promise<void>
|
|
onClose: () => void
|
|
disabled?: boolean
|
|
}
|
|
|
|
export default function PasteLyricsTab({
|
|
onAdd,
|
|
onClose,
|
|
disabled = false,
|
|
}: PasteLyricsTabProps) {
|
|
const t = useTranslations('lyricsReview.modals.pasteLyrics')
|
|
const [source, setSource] = useState('')
|
|
const [lyrics, setLyrics] = useState('')
|
|
const [isAdding, setIsAdding] = useState(false)
|
|
const [error, setError] = useState<string | null>(null)
|
|
|
|
const handleAdd = async () => {
|
|
if (!source.trim() || !lyrics.trim()) return
|
|
|
|
setIsAdding(true)
|
|
setError(null)
|
|
|
|
try {
|
|
await onAdd(source.trim(), lyrics.trim())
|
|
setSource('')
|
|
setLyrics('')
|
|
onClose()
|
|
} catch (err) {
|
|
setError(err instanceof Error ? err.message : 'Failed to add lyrics')
|
|
} finally {
|
|
setIsAdding(false)
|
|
}
|
|
}
|
|
|
|
const handleCancel = () => {
|
|
if (!isAdding) {
|
|
setSource('')
|
|
setLyrics('')
|
|
setError(null)
|
|
onClose()
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className="space-y-4">
|
|
<div className="space-y-2">
|
|
<Label htmlFor="paste-source">{t('sourceName')}</Label>
|
|
<Input
|
|
id="paste-source"
|
|
value={source}
|
|
onChange={(e) => setSource(e.target.value)}
|
|
placeholder={t('sourceNamePlaceholder')}
|
|
disabled={isAdding || disabled}
|
|
/>
|
|
</div>
|
|
|
|
<div className="space-y-2">
|
|
<Label htmlFor="paste-lyrics">{t('lyrics')}</Label>
|
|
<Textarea
|
|
id="paste-lyrics"
|
|
value={lyrics}
|
|
onChange={(e) => setLyrics(e.target.value)}
|
|
placeholder={t('lyricsPlaceholder')}
|
|
rows={10}
|
|
disabled={isAdding || disabled}
|
|
className="font-mono text-sm"
|
|
/>
|
|
</div>
|
|
|
|
{error && <p className="text-sm text-destructive">{error}</p>}
|
|
|
|
<div className="flex justify-end gap-2 pt-2">
|
|
<Button variant="outline" onClick={handleCancel} disabled={isAdding || disabled}>
|
|
Cancel
|
|
</Button>
|
|
<Button
|
|
onClick={handleAdd}
|
|
disabled={isAdding || disabled || !source.trim() || !lyrics.trim()}
|
|
>
|
|
{isAdding ? (
|
|
<>
|
|
<Loader2 className="h-4 w-4 mr-2 animate-spin" />
|
|
{t('adding')}
|
|
</>
|
|
) : (
|
|
t('addLyrics')
|
|
)}
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|