diff --git a/src/components/StatusView.tsx b/src/components/StatusView.tsx index b6e4493..a442cea 100644 --- a/src/components/StatusView.tsx +++ b/src/components/StatusView.tsx @@ -1,6 +1,7 @@ 'use client' import { useEffect, useState } from 'react' +import { useTranslations, useLocale } from 'next-intl' type DownloadData = { uuid: string @@ -15,6 +16,8 @@ type DownloadData = { } export function StatusView({ uuid }: { uuid: string }) { + const t = useTranslations('status') + const locale = useLocale() const [data, setData] = useState(null) const [notFound, setNotFound] = useState(false) @@ -42,35 +45,35 @@ export function StatusView({ uuid }: { uuid: string }) { return () => { active = false } }, [uuid]) - if (notFound) return

Telechargement introuvable.

- if (!data) return

Chargement...

+ if (notFound) return

{t('notFound')}

+ if (!data) return

{t('loading')}

if (data.status === 'PENDING' || data.status === 'PROCESSING') { return (
-

Statut : {data.status === 'PENDING' ? 'En attente' : 'En cours...'}

-

Cette page se rafraichit automatiquement toutes les 5 secondes.

+

{data.status === 'PENDING' ? t('pending') : t('processing')}

+

{t('polling')}

) } if (data.status === 'DONE' && data.downloadToken) { const sizeMb = data.fileSize - ? `(${(Number(data.fileSize) / 1_048_576).toFixed(1)} Mo)` + ? `(${(Number(data.fileSize) / 1_048_576).toFixed(1)} MB)` : '' return (
-

Telechargement pret {sizeMb}

+

{t('ready')} {sizeMb}

- Telecharger {data.fileName} + {t('download')} {data.fileName} {data.tokenExpiresAt && (

- Lien valable jusqu'au{' '} - {new Date(data.tokenExpiresAt).toLocaleString('fr-FR')} + {t('linkExpires')}{' '} + {new Date(data.tokenExpiresAt).toLocaleString(locale)}

)}
@@ -80,7 +83,7 @@ export function StatusView({ uuid }: { uuid: string }) { if (data.status === 'FAILED') { return (
-

Echec du telechargement.

+

{t('failed')}

           {data.errorMsg}
         
@@ -89,13 +92,8 @@ export function StatusView({ uuid }: { uuid: string }) { } if (data.status === 'FILE_DELETED') { - return ( -

- Le fichier a expire et a ete supprime. Le telechargement n'est plus - disponible. -

- ) + return

{t('deleted')}

} - return

Statut inconnu : {data.status}

+ return

{t('unknown')}: {data.status}

} diff --git a/src/components/SubmitForm.tsx b/src/components/SubmitForm.tsx index 8d03798..23f1639 100644 --- a/src/components/SubmitForm.tsx +++ b/src/components/SubmitForm.tsx @@ -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 (