feat: add i18n support (FR/EN) to backoffice with English as default

Implement full internationalization for the Next.js backoffice:
- i18n infrastructure: type-safe dictionaries (fr.ts/en.ts), cookie-based locale detection, React Context for client components, server-side translation helper
- Language selector in Settings page (General tab) with cookie + DB persistence
- All ~35 pages and components translated via t() / useTranslation()
- Default locale set to English, French available via settings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-18 19:39:01 +01:00
parent 055c376222
commit d4f87c4044
43 changed files with 2024 additions and 693 deletions

View File

@@ -3,6 +3,7 @@
import { useState } from "react";
import Link from "next/link";
import { Button } from "./ui";
import { useTranslation } from "../../lib/i18n/context";
interface ConvertButtonProps {
bookId: string;
@@ -15,6 +16,7 @@ type ConvertState =
| { type: "error"; message: string };
export function ConvertButton({ bookId }: ConvertButtonProps) {
const { t } = useTranslation();
const [state, setState] = useState<ConvertState>({ type: "idle" });
const handleConvert = async () => {
@@ -23,22 +25,22 @@ export function ConvertButton({ bookId }: ConvertButtonProps) {
const res = await fetch(`/api/books/${bookId}/convert`, { method: "POST" });
if (!res.ok) {
const body = await res.json().catch(() => ({ error: res.statusText }));
setState({ type: "error", message: body.error || "Échec de la conversion" });
setState({ type: "error", message: body.error || t("convert.failed") });
return;
}
const job = await res.json();
setState({ type: "success", jobId: job.id });
} catch (err) {
setState({ type: "error", message: err instanceof Error ? err.message : "Erreur inconnue" });
setState({ type: "error", message: err instanceof Error ? err.message : t("convert.unknownError") });
}
};
if (state.type === "success") {
return (
<div className="flex items-center gap-2 text-sm text-success">
<span>Conversion lancée.</span>
<span>{t("convert.started")}</span>
<Link href={`/jobs/${state.jobId}`} className="text-primary hover:underline font-medium">
Voir la tâche
{t("convert.viewJob")}
</Link>
</div>
);
@@ -52,7 +54,7 @@ export function ConvertButton({ bookId }: ConvertButtonProps) {
className="text-xs text-muted-foreground hover:underline text-left"
onClick={() => setState({ type: "idle" })}
>
Fermer
{t("common.close")}
</button>
</div>
);
@@ -65,7 +67,7 @@ export function ConvertButton({ bookId }: ConvertButtonProps) {
onClick={handleConvert}
disabled={state.type === "loading"}
>
{state.type === "loading" ? "Conversion…" : "Convertir en CBZ"}
{state.type === "loading" ? t("convert.converting") : t("convert.convertToCbz")}
</Button>
);
}