feat: translate SubmitForm and StatusView with next-intl

This commit is contained in:
2026-08-10 15:35:21 +02:00
parent a89095b5c4
commit e7af883953
2 changed files with 26 additions and 26 deletions
+11 -9
View File
@@ -1,12 +1,14 @@
'use client'
import { useState, FormEvent } from 'react'
import { useRouter } from 'next/navigation'
import { useTranslations } from 'next-intl'
import { useRouter } from '@/navigation'
const FORMATS = ['mp4', 'mp3', 'webm', 'mkv']
const QUALITIES = ['best', '1080p', '720p', '480p', '360p']
export function SubmitForm() {
const t = useTranslations('home')
const router = useRouter()
const [url, setUrl] = useState('')
const [format, setFormat] = useState('mp4')
@@ -36,12 +38,12 @@ export function SubmitForm() {
setLoading(false)
if (res.status === 429) {
setError('Trop de soumissions. Reessayez dans une heure.')
setError(t('errorRateLimit'))
return
}
if (!res.ok) {
const body = await res.json().catch(() => ({}))
setError((body as { error?: string }).error ?? 'Erreur lors de la soumission.')
setError((body as { error?: string }).error ?? t('errorGeneric'))
return
}
@@ -52,7 +54,7 @@ export function SubmitForm() {
return (
<form onSubmit={handleSubmit} style={{ display: 'flex', flexDirection: 'column', gap: '1rem', maxWidth: 480 }}>
<label>
URL de la video
{t('urlLabel')}
<input
type="url"
value={url}
@@ -64,14 +66,14 @@ export function SubmitForm() {
</label>
<label>
Format
{t('format')}
<select value={format} onChange={(e) => setFormat(e.target.value)} style={{ display: 'block' }}>
{FORMATS.map((f) => <option key={f}>{f}</option>)}
</select>
</label>
<label>
Qualite
{t('quality')}
<select value={quality} onChange={(e) => setQuality(e.target.value)} style={{ display: 'block' }}>
{QUALITIES.map((q) => <option key={q}>{q}</option>)}
</select>
@@ -83,11 +85,11 @@ export function SubmitForm() {
checked={subtitles}
onChange={(e) => setSubtitles(e.target.checked)}
/>{' '}
Telecharger les sous-titres (fr, en)
{t('subtitles')}
</label>
<label>
Options avancees (optionnel, JSON)
{t('advanced')}
<input
type="text"
value={extraArgs}
@@ -100,7 +102,7 @@ export function SubmitForm() {
{error && <p style={{ color: 'red' }}>{error}</p>}
<button type="submit" disabled={loading}>
{loading ? 'Envoi...' : 'Telecharger'}
{loading ? t('submitting') : t('submit')}
</button>
</form>
)