feat: translate SubmitForm and StatusView with next-intl
This commit is contained in:
@@ -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>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user