diff --git a/frontend/public/theme.js b/frontend/public/theme.js
index f2c3678..22f002e 100644
--- a/frontend/public/theme.js
+++ b/frontend/public/theme.js
@@ -1,9 +1,10 @@
(function () {
try {
var stored = localStorage.getItem("cohaise-theme");
+ var theme = stored === "light" || stored === "dark" ? stored : "system";
var prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
- var theme = stored || (prefersDark ? "dark" : "light");
- if (theme === "dark") document.documentElement.classList.add("dark");
+ var dark = theme === "dark" || (theme === "system" && prefersDark);
+ document.documentElement.classList.toggle("dark", dark);
} catch (error) {
void error;
}
diff --git a/frontend/src/components/AppShell.tsx b/frontend/src/components/AppShell.tsx
index 4c8d59c..0d7d90c 100644
--- a/frontend/src/components/AppShell.tsx
+++ b/frontend/src/components/AppShell.tsx
@@ -2,6 +2,7 @@ import { useState } from "react";
import { NavLink, Outlet } from "react-router-dom";
import { Button, cn } from "../ui/index.js";
import { useSession } from "../lib/session.js";
+import { useI18n } from "../lib/i18n.js";
import { Avatar } from "./Avatar.js";
import {
ActivityIcon,
@@ -50,6 +51,7 @@ const navClass = ({ isActive }: { isActive: boolean }) =>
export const AppShell = () => {
const { user, logout } = useSession();
+ const { t } = useI18n();
const [menuOpen, setMenuOpen] = useState(false);
if (!user) return null;
@@ -80,7 +82,7 @@ export const AppShell = () => {
return (
- Administration + {t("Administration")}
{ADMIN_NAV.map(renderLink)} > @@ -108,7 +110,7 @@ export const AppShell = () => { diff --git a/frontend/src/components/FolderChat.tsx b/frontend/src/components/FolderChat.tsx index fbb382a..22ae76d 100644 --- a/frontend/src/components/FolderChat.tsx +++ b/frontend/src/components/FolderChat.tsx @@ -9,6 +9,8 @@ import { } from "react"; import { Button, Spinner, cn } from "../ui/index.js"; import { ApiError, api, formatDate, type ChatMember, type ChatMessage } from "../lib/api.js"; +import { useI18n } from "../lib/i18n.js"; +import { getLocale } from "../lib/locale.js"; import { useSession } from "../lib/session.js"; import { useConfirm } from "./confirm.js"; import { Avatar } from "./Avatar.js"; @@ -22,10 +24,10 @@ const POLL_MEMBERS_MS = 30_000; const GROUP_WINDOW_MS = 5 * 60 * 1000; const timeOf = (value: string): string => - new Date(value).toLocaleTimeString("fr-FR", { hour: "2-digit", minute: "2-digit" }); + new Date(value).toLocaleTimeString(getLocale(), { hour: "2-digit", minute: "2-digit" }); const dayOf = (value: string): string => - new Date(value).toLocaleDateString("fr-FR", { + new Date(value).toLocaleDateString(getLocale(), { weekday: "long", day: "numeric", month: "long", @@ -34,8 +36,10 @@ const dayOf = (value: string): string => const isSameDay = (a: string, b: string): boolean => new Date(a).toDateString() === new Date(b).toDateString(); -const fullName = (member: { first_name: string | null; last_name: string | null }): string => - `${member.first_name ?? ""} ${member.last_name ?? ""}`.trim() || "Compte supprimé"; +const fullName = ( + member: { first_name: string | null; last_name: string | null }, + fallback: string, +): string => `${member.first_name ?? ""} ${member.last_name ?? ""}`.trim() || fallback; const MAX_ID = (list: ChatMessage[]): number => list.reduce((max, message) => Math.max(max, message.id), 0); @@ -52,6 +56,7 @@ export interface ChatFolder { * chaque requete, l'interface ne fait que l'afficher. */ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: () => void }) => { + const { t } = useI18n(); const { user } = useSession(); const confirm = useConfirm(); const folderId = folder.id; @@ -114,7 +119,7 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: ( setError(null); } catch (caught) { if (!active) return; - setError(caught instanceof ApiError ? caught.message : "Chargement impossible."); + setError(caught instanceof ApiError ? caught.message : t("Chargement impossible.")); } finally { if (active) { setLoading(false); @@ -189,7 +194,7 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: ( mergeMessages([message]); setDraft(""); } catch (caught) { - setError(caught instanceof ApiError ? caught.message : "Envoi impossible."); + setError(caught instanceof ApiError ? caught.message : t("Envoi impossible.")); } finally { setSending(false); } @@ -198,9 +203,9 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: ( const remove = async (message: ChatMessage) => { if ( !(await confirm({ - title: "Supprimer le message", - message: "Ce message sera retiré du salon pour tout le monde.", - confirmLabel: "Supprimer", + title: t("Supprimer le message"), + message: t("Ce message sera retiré du salon pour tout le monde."), + confirmLabel: t("Supprimer"), tone: "danger", })) ) @@ -210,7 +215,7 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: ( await api.chatDeleteMessage(folderId, message.id); setMessages((previous) => previous.filter((item) => item.id !== message.id)); } catch (caught) { - setError(caught instanceof ApiError ? caught.message : "Suppression impossible."); + setError(caught instanceof ApiError ? caught.message : t("Suppression impossible.")); } finally { setDeletingId(null); } @@ -249,11 +254,11 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: ( "absolute inset-y-0 left-0 z-20 flex w-64 flex-col border-r border-border bg-surface transition-transform md:static md:z-auto md:translate-x-0", membersOpen ? "translate-x-0 shadow-lg md:shadow-none" : "-translate-x-full", )} - aria-label="Membres du dossier" + aria-label={t("Membres du dossier")} >- {fullName(member)} + {fullName(member, t("Compte supprimé"))} {member.is_self ? ( - (vous) + {t("(vous)")} ) : null}
{member.last_login_at - ? `Dernière connexion le ${formatDate(member.last_login_at)}` - : "Jamais connecté"} + ? t("Dernière connexion le {date}", { + date: formatDate(member.last_login_at), + }) + : t("Jamais connecté")}
- Membres ayant accès à ce dossier + {t("Membres ayant accès à ce dossier")}
Lecture impossible.
; - if (text === null) returnChargement…
; + if (failed) return{t("Lecture impossible.")}
; + if (text === null) return{t("Chargement…")}
; return (
{text}
@@ -66,33 +68,37 @@ const Panel = ({
item: MediaViewerItem;
message: string;
openable: boolean;
-}) => (
-
-
-
- {item.name}
- {message}
-
-
- {openable ? (
-
- Ouvrir
+}) => {
+ const { t } = useI18n();
+ return (
+
+
+
+ {item.name}
+ {message}
+
+
+ {openable ? (
+
+ {t("Ouvrir")}
+
+ ) : null}
+
+
+ {t("Télécharger")}
- ) : null}
-
-
- Télécharger
-
+
-
-);
+ );
+};
const Body = ({ item }: { item: MediaViewerItem }) => {
+ const { t } = useI18n();
const kind = kindOf(item.mime_type);
if (kind === "image") {
return (
@@ -124,11 +130,11 @@ const Body = ({ item }: { item: MediaViewerItem }) => {
}
if (kind === "text") return ;
if (kind === "pdf") {
- return (
-
- );
+ return ;
}
- return ;
+ return (
+
+ );
};
export const MediaViewer = ({
@@ -140,6 +146,7 @@ export const MediaViewer = ({
startIndex: number;
onClose: () => void;
}) => {
+ const { t } = useI18n();
const [index, setIndex] = useState(startIndex);
const current = items[index];
@@ -169,11 +176,11 @@ export const MediaViewer = ({
href={api.downloadUrl(current.id)}
download={current.name}
className={controlClass}
- aria-label="Télécharger"
+ aria-label={t("Télécharger")}
>
-
+
@@ -190,7 +197,7 @@ export const MediaViewer = ({
type="button"
onClick={() => setIndex((value) => value - 1)}
className={cn(controlClass, "absolute left-4 z-10")}
- aria-label="Fichier précédent"
+ aria-label={t("Fichier précédent")}
>
@@ -203,7 +210,7 @@ export const MediaViewer = ({
type="button"
onClick={() => setIndex((value) => value + 1)}
className={cn(controlClass, "absolute right-4 z-10")}
- aria-label="Fichier suivant"
+ aria-label={t("Fichier suivant")}
>
diff --git a/frontend/src/components/confirm.tsx b/frontend/src/components/confirm.tsx
index b888262..ed8da6e 100644
--- a/frontend/src/components/confirm.tsx
+++ b/frontend/src/components/confirm.tsx
@@ -6,6 +6,7 @@ import {
type ReactNode,
} from "react";
import { Button } from "../ui/index.js";
+import { useI18n } from "../lib/i18n.js";
import { Modal } from "./feedback.js";
export interface ConfirmOptions {
@@ -33,6 +34,7 @@ const ConfirmContext = createContext(null);
* `useConfirm()` renvoie une promesse resolue a `true` (confirme) ou `false`.
*/
export const ConfirmProvider = ({ children }: { children: ReactNode }) => {
+ const { t } = useI18n();
const [pending, setPending] = useState(null);
const confirm = useCallback(
@@ -52,7 +54,7 @@ export const ConfirmProvider = ({ children }: { children: ReactNode }) => {
{children}
answer(false)}
>
@@ -61,7 +63,7 @@ export const ConfirmProvider = ({ children }: { children: ReactNode }) => {
answer(false)}>
- {pending?.options.cancelLabel ?? "Annuler"}
+ {pending?.options.cancelLabel ?? t("Annuler")}
{
autoFocus
onClick={() => answer(true)}
>
- {pending?.options.confirmLabel ?? "Confirmer"}
+ {pending?.options.confirmLabel ?? t("Confirmer")}
diff --git a/frontend/src/components/dialogs.tsx b/frontend/src/components/dialogs.tsx
index 13bcca2..fb67baf 100644
--- a/frontend/src/components/dialogs.tsx
+++ b/frontend/src/components/dialogs.tsx
@@ -4,9 +4,11 @@ import {
ApiError,
api,
formatDate,
+ type DirectoryUser,
type Folder,
type FolderPermission,
} from "../lib/api.js";
+import { useI18n } from "../lib/i18n.js";
import { Alert, Modal } from "./feedback.js";
import { TrashIcon } from "./icons.js";
@@ -35,8 +37,8 @@ export const CreateFolderDialog = ({
onClose: () => void;
onCreated: () => void;
}) => {
+ const { t } = useI18n();
const [name, setName] = useState("");
- const [description, setDescription] = useState("");
const [error, setError] = useState(null);
const [busy, setBusy] = useState(false);
@@ -45,40 +47,34 @@ export const CreateFolderDialog = ({
setBusy(true);
setError(null);
try {
- await api.createFolder(name, parentId, description.trim() || undefined);
+ await api.createFolder(name, parentId);
onCreated();
} catch (caught) {
- setError(messageOf(caught, "Création impossible."));
+ setError(messageOf(caught, t("Création impossible.")));
} finally {
setBusy(false);
}
};
return (
-
+
@@ -95,6 +91,7 @@ export const RenameDialog = ({
onClose: () => void;
onDone: () => void;
}) => {
+ const { t } = useI18n();
const [name, setName] = useState(target.name);
const [error, setError] = useState(null);
const [busy, setBusy] = useState(false);
@@ -104,21 +101,21 @@ export const RenameDialog = ({
setBusy(true);
setError(null);
try {
- if (target.type === "folder") await api.updateFolder(target.id, { name });
+ if (target.type === "folder") await api.updateFolder(target.id, name);
else await api.renameFile(target.id, name);
onDone();
} catch (caught) {
- setError(messageOf(caught, "Renommage impossible."));
+ setError(messageOf(caught, t("Renommage impossible.")));
} finally {
setBusy(false);
}
};
return (
-
+
@@ -167,6 +164,7 @@ export const MoveDialog = ({
onClose: () => void;
onDone: () => void;
}) => {
+ const { t } = useI18n();
const [entries, setEntries] = useState(null);
const [destination, setDestination] = useState("");
const [error, setError] = useState(null);
@@ -175,7 +173,7 @@ export const MoveDialog = ({
useEffect(() => {
loadTree()
.then(setEntries)
- .catch((caught: unknown) => setError(messageOf(caught, "Chargement des dossiers impossible.")));
+ .catch((caught: unknown) => setError(messageOf(caught, t("Chargement des dossiers impossible."))));
}, []);
const submit = async (event: FormEvent) => {
@@ -188,24 +186,24 @@ export const MoveDialog = ({
else await api.moveFile(target.id, parentId);
onDone();
} catch (caught) {
- setError(messageOf(caught, "Déplacement impossible."));
+ setError(messageOf(caught, t("Déplacement impossible.")));
} finally {
setBusy(false);
}
};
return (
-
+
@@ -247,7 +245,9 @@ export const ShareDialog = ({
folder: Folder;
onClose: () => void;
}) => {
+ const { t } = useI18n();
const [permissions, setPermissions] = useState(null);
+ const [members, setMembers] = useState(null);
const [email, setEmail] = useState("");
const [level, setLevel] = useState("read");
const [expiresAt, setExpiresAt] = useState("");
@@ -256,12 +256,17 @@ export const ShareDialog = ({
const load = async () => {
try {
- const { permissions: list } = await api.folderPermissions(folder.id);
+ const [{ permissions: list }, { users }] = await Promise.all([
+ api.folderPermissions(folder.id),
+ api.directory(),
+ ]);
setPermissions(list);
+ setMembers(users);
setError(null);
} catch (caught) {
- setError(messageOf(caught, "Chargement des partages impossible."));
+ setError(messageOf(caught, t("Chargement des partages impossible.")));
setPermissions([]);
+ setMembers([]);
}
};
@@ -270,6 +275,10 @@ export const ShareDialog = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [folder.id]);
+ const candidates = (members ?? []).filter(
+ (member) => !(permissions ?? []).some((permission) => permission.user_id === member.id),
+ );
+
const grant = async (event: FormEvent) => {
event.preventDefault();
setBusy(true);
@@ -281,7 +290,7 @@ export const ShareDialog = ({
setExpiresAt("");
await load();
} catch (caught) {
- setError(messageOf(caught, "Partage impossible."));
+ setError(messageOf(caught, t("Partage impossible.")));
} finally {
setBusy(false);
}
@@ -293,26 +302,43 @@ export const ShareDialog = ({
await api.revokePermission(folder.id, userId);
await load();
} catch (caught) {
- setError(messageOf(caught, "Révocation impossible."));
+ setError(messageOf(caught, t("Révocation impossible.")));
}
};
return (
-
+
- Accès accordés
+ {t("Accès accordés")}
{permissions === null ? (
- Chargement…
+ {t("Chargement…")}
) : permissions.length === 0 ? (
- Aucun partage pour ce dossier.
+ {t("Aucun partage pour ce dossier.")}
) : (
{permissions.map((permission) => (
@@ -358,13 +384,18 @@ export const ShareDialog = ({
{permission.first_name} {permission.last_name}
- {permission.email} · {LEVEL_LABEL[permission.level] ?? permission.level}
- {permission.expires_at ? ` · jusqu'au ${formatDate(permission.expires_at)}` : ""}
+ {permission.email} ·{" "}
+ {permission.expires_at
+ ? t("{level} · jusqu'au {date}", {
+ level: t(LEVEL_LABEL[permission.level] ?? permission.level),
+ date: formatDate(permission.expires_at),
+ })
+ : t(LEVEL_LABEL[permission.level] ?? permission.level)}
void revoke(permission.user_id)}
className="inline-flex h-8 w-8 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:text-destructive"
>
diff --git a/frontend/src/components/feedback.tsx b/frontend/src/components/feedback.tsx
index 0574a8d..4e80b9d 100644
--- a/frontend/src/components/feedback.tsx
+++ b/frontend/src/components/feedback.tsx
@@ -1,5 +1,6 @@
import { useEffect, type ReactNode } from "react";
import { cn } from "../ui/index.js";
+import { useI18n } from "../lib/i18n.js";
import { CloseIcon } from "./icons.js";
export const Modal = ({
@@ -13,6 +14,8 @@ export const Modal = ({
onClose: () => void;
children: ReactNode;
}) => {
+ const { t } = useI18n();
+
useEffect(() => {
if (!open) return;
const onKeyDown = (event: KeyboardEvent) => {
@@ -48,7 +51,7 @@ export const Modal = ({
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts
index 410b18d..2c68e5f 100644
--- a/frontend/src/lib/api.ts
+++ b/frontend/src/lib/api.ts
@@ -1,3 +1,8 @@
+import { getLanguage, getLocale } from "./locale";
+
+export type Theme = "system" | "light" | "dark";
+export type Language = "fr" | "en";
+
export interface User {
id: string;
email: string;
@@ -9,6 +14,8 @@ export interface User {
used_bytes: number;
max_file_bytes: number;
must_change_password: boolean;
+ theme: Theme;
+ language: Language;
has_avatar: boolean;
avatar_updated_at: string | null;
}
@@ -17,7 +24,6 @@ export interface Folder {
id: string;
parent_id: string | null;
name: string;
- description: string | null;
owner_id: string | null;
access_type: string;
is_system: boolean;
@@ -67,7 +73,6 @@ export interface TrashFolder {
id: string;
parent_id: string | null;
name: string;
- description: string | null;
owner_id: string | null;
access_type: string;
created_at: string;
@@ -171,6 +176,15 @@ export interface ChatMessage {
avatar_updated_at: string | null;
}
+export interface DirectoryUser {
+ id: string;
+ first_name: string;
+ last_name: string;
+ email: string;
+ has_avatar: boolean;
+ avatar_updated_at: string | null;
+}
+
export class ApiError extends Error {
readonly status: number;
@@ -268,6 +282,9 @@ export const api = {
// --- Compte ------------------------------------------------------------
updateProfile: (first_name: string, last_name: string) =>
patch<{ ok: boolean }>("/account/profile", { first_name, last_name }),
+ preferences: () => request<{ theme: Theme; language: Language }>("/account/preferences"),
+ updatePreferences: (theme: Theme, language: Language) =>
+ patch<{ theme: Theme; language: Language }>("/account/preferences", { theme, language }),
sessions: () => request<{ sessions: SessionInfo[] }>("/account/sessions"),
revokeSession: (id: string) => del<{ ok: boolean }>(`/account/sessions/${encodeURIComponent(id)}`),
revokeOtherSessions: () => del<{ ok: boolean }>("/account/sessions"),
@@ -275,15 +292,16 @@ export const api = {
uploadAvatar: (file: File) => putBinary<{ ok: boolean }>("/account/avatar", file, file.type),
deleteAvatar: () => del<{ ok: boolean }>("/account/avatar"),
+ directory: () => request<{ users: DirectoryUser[] }>("/directory"),
// --- Dossiers ----------------------------------------------------------
folders: (parentId?: string | null) =>
request<{ parentId: string | null; folders: Folder[] }>(
`/folders${query({ parentId })}`,
),
- createFolder: (name: string, parentId?: string | null, description?: string) =>
- post<{ folder: Folder }>("/folders", { name, parentId: parentId ?? null, description }),
- updateFolder: (id: string, payload: { name?: string; description?: string | null }) =>
- patch<{ folder: Folder }>(`/folders/${encodeURIComponent(id)}`, payload),
+ createFolder: (name: string, parentId?: string | null) =>
+ post<{ folder: Folder }>("/folders", { name, parentId: parentId ?? null }),
+ updateFolder: (id: string, name: string) =>
+ patch<{ folder: Folder }>(`/folders/${encodeURIComponent(id)}`, { name }),
moveFolder: (id: string, parentId: string | null) =>
post<{ folder: Folder }>(`/folders/${encodeURIComponent(id)}/move`, { parentId }),
deleteFolder: (id: string) => del<{ ok: boolean }>(`/folders/${encodeURIComponent(id)}`),
@@ -352,6 +370,7 @@ export const api = {
post<{ message: ChatMessage }>(`/folders/${encodeURIComponent(folderId)}/chat/messages`, { body }),
chatDeleteMessage: (folderId: string, id: number) =>
del<{ ok: boolean }>(`/folders/${encodeURIComponent(folderId)}/chat/messages/${id}`),
+ chatUnread: () => request<{ unread: Record }>("/chat/unread"),
// --- Administration ----------------------------------------------------
adminStats: () => request("/admin/stats"),
@@ -391,22 +410,27 @@ export const api = {
id: number,
payload: { name?: string; quota_bytes?: number | null; is_active?: boolean },
) => patch<{ ok: boolean }>(`/admin/storage-locations/${id}`, payload),
- adminAudit: (limit = 100, offset = 0, action?: string) =>
- request<{ entries: AuditEntry[] }>(`/admin/audit${query({ limit, offset, action })}`),
+ adminAudit: (limit = 100, offset = 0, action?: string, userId?: string) =>
+ request<{ entries: AuditEntry[] }>(`/admin/audit${query({ limit, offset, action, userId })}`),
+ adminAuditFilters: () =>
+ request<{ actions: string[]; users: { id: string; email: string | null }[] }>(
+ "/admin/audit/filters",
+ ),
};
/** Octets en lecture humaine, sans precision inutile. */
export const formatBytes = (bytes: number): string => {
- if (bytes < 1024) return `${bytes} o`;
- const units = ["Ko", "Mo", "Go", "To"];
+ const english = getLanguage() === "en";
+ if (bytes < 1024) return `${bytes} ${english ? "B" : "o"}`;
+ const units = english ? ["KB", "MB", "GB", "TB"] : ["Ko", "Mo", "Go", "To"];
let value = bytes;
let index = -1;
do {
value /= 1024;
index += 1;
} while (value >= 1024 && index < units.length - 1);
- return `${value.toLocaleString("fr-FR", { maximumFractionDigits: value < 10 ? 1 : 0 })} ${units[index]}`;
+ return `${value.toLocaleString(getLocale(), { maximumFractionDigits: value < 10 ? 1 : 0 })} ${units[index]}`;
};
export const formatDate = (value: string | null): string =>
- value ? new Date(value).toLocaleString("fr-FR", { dateStyle: "medium", timeStyle: "short" }) : "—";
+ value ? new Date(value).toLocaleString(getLocale(), { dateStyle: "medium", timeStyle: "short" }) : "—";
diff --git a/frontend/src/lib/i18n.tsx b/frontend/src/lib/i18n.tsx
new file mode 100644
index 0000000..082f70e
--- /dev/null
+++ b/frontend/src/lib/i18n.tsx
@@ -0,0 +1,375 @@
+import {
+ createContext,
+ useCallback,
+ useContext,
+ useMemo,
+ type ReactNode,
+} from "react";
+import type { Language } from "./api.js";
+import { setLanguage } from "./locale.js";
+
+/**
+ * Traduction par clef de source : la chaine francaise sert de clef, le
+ * dictionnaire anglais fournit la variante. Une clef absente retombe sur le
+ * francais, donc un oubli ne casse jamais l'interface.
+ */
+const en: Record = {
+ // --- Commun ------------------------------------------------------------
+ "Annuler": "Cancel",
+ "Enregistrer": "Save",
+ "Créer": "Create",
+ "Supprimer": "Delete",
+ "Confirmer": "Confirm",
+ "Fermer": "Close",
+ "Retour": "Back",
+ "Filtrer": "Filter",
+ "Tous les utilisateurs": "All users",
+ "Toutes les actions": "All actions",
+ "Type d'action": "Action type",
+ "Charger plus": "Load more",
+ "Chargement…": "Loading…",
+ "Chargement impossible.": "Unable to load.",
+ "Action impossible.": "Action failed.",
+ "Envoi impossible.": "Upload failed.",
+ "Suppression impossible.": "Deletion failed.",
+ "Enregistrement impossible.": "Saving failed.",
+ "Création impossible.": "Creation failed.",
+ "Mise à jour impossible.": "Update failed.",
+ "Réinitialisation impossible.": "Reset failed.",
+ "Révocation impossible.": "Revocation failed.",
+ "Déplacement impossible.": "Move failed.",
+ "Renommage impossible.": "Rename failed.",
+ "Partage impossible.": "Sharing failed.",
+ "Demande impossible.": "Request failed.",
+ "Confirmation impossible.": "Confirmation failed.",
+ "Recherche impossible.": "Search failed.",
+ "Changement impossible.": "Change failed.",
+ "Connexion impossible.": "Unable to sign in.",
+ "Chargement des dossiers impossible.": "Unable to load folders.",
+ "Chargement des dossiers…": "Loading folders…",
+ "Chargement des partages impossible.": "Unable to load shares.",
+
+ // --- Navigation / coque ------------------------------------------------
+ "Fichiers": "Files",
+ "Favoris": "Favorites",
+ "Recherche": "Search",
+ "Galerie": "Gallery",
+ "Corbeille": "Trash",
+ "Comptes": "Accounts",
+ "Stockage": "Storage",
+ "Journal": "Log",
+ "Mon compte": "My account",
+ "Administration": "Administration",
+ "Déconnexion": "Sign out",
+ "Fermer le menu": "Close menu",
+ "Ouvrir le menu": "Open menu",
+
+ // --- Connexion ---------------------------------------------------------
+ "Connectez-vous pour accéder à vos fichiers.": "Sign in to access your files.",
+ "Connexion": "Sign in",
+ "Votre session reste ouverte 14 jours.": "Your session stays open for 14 days.",
+ "Adresse e-mail": "Email address",
+ "Mot de passe": "Password",
+ "Se connecter": "Sign in",
+ "Mot de passe oublié ?": "Forgot your password?",
+
+ // --- Mot de passe oublié ----------------------------------------------
+ "Mot de passe oublié": "Forgot password",
+ "Réinitialisation": "Reset",
+ "Nous vous enverrons un lien valable une heure.": "We will email you a link valid for one hour.",
+ "Si cette adresse correspond à un compte, un message contenant le lien de réinitialisation vient d'être envoyé.":
+ "If this address matches an account, a message with the reset link has just been sent.",
+ "Retour à la connexion": "Back to sign in",
+ "Envoyer le lien": "Send link",
+
+ // --- Réinitialisation --------------------------------------------------
+ "Nouveau mot de passe": "New password",
+ "Choisissez un mot de passe robuste.": "Choose a strong password.",
+ "Ce lien est incomplet ou invalide.": "This link is incomplete or invalid.",
+ "Demander un nouveau lien": "Request a new link",
+ "Votre mot de passe a été réinitialisé. Vous pouvez vous connecter.":
+ "Your password has been reset. You can now sign in.",
+ "Confirmation": "Confirmation",
+ "8 caractères minimum.": "At least 8 characters.",
+ "Réinitialiser": "Reset",
+ "Les deux mots de passe ne correspondent pas.": "The two passwords do not match.",
+
+ // --- Changement d'adresse ---------------------------------------------
+ "Changement d'adresse": "Email change",
+ "Votre adresse e-mail a été mise à jour.": "Your email address has been updated.",
+ "Accéder à mes fichiers": "Go to my files",
+
+ // --- Changement de mot de passe ---------------------------------------
+ "Bienvenue {name}. Ce mot de passe a été défini par un administrateur : choisissez le vôtre.":
+ "Welcome {name}. This password was set by an administrator: choose your own.",
+ "Changement requis": "Change required",
+ "Les autres sessions ouvertes sur ce compte seront fermées.":
+ "Other sessions open on this account will be closed.",
+ "Mot de passe actuel": "Current password",
+ "Se déconnecter": "Sign out",
+
+ // --- Explorateur -------------------------------------------------------
+ "Racine": "Root",
+ "Vos dossiers et fichiers. Envoyez un fichier ou créez un dossier.":
+ "Your folders and files. Upload a file or create a folder.",
+ "Fil d'Ariane": "Breadcrumb",
+ "Discussion": "Discussion",
+ "Espace utilisé": "Space used",
+ "{used} sur {quota}": "{used} of {quota}",
+ "Envoyer": "Upload",
+ "Nouveau dossier": "New folder",
+ "Contrats 2026": "Contracts 2026",
+ "Emplacement vide": "Empty location",
+ "Créez un sous-dossier ou envoyez un fichier pour commencer.":
+ "Create a subfolder or upload a file to get started.",
+ "Dossiers": "Folders",
+ "Aperçu de {name}": "Preview of {name}",
+ "Retirer l'étoile de {name}": "Remove star from {name}",
+ "Étoiler {name}": "Star {name}",
+ "Télécharger": "Download",
+ "Renommer {name}": "Rename {name}",
+ "Déplacer {name}": "Move {name}",
+ "Supprimer {name}": "Delete {name}",
+ "Partager {name}": "Share {name}",
+ "Discussion {name}": "Discussion {name}",
+ "Mettre à la corbeille": "Move to trash",
+ "ce dossier": "this folder",
+ "ce fichier": "this file",
+ "Placer {name} ({kind}) dans la corbeille ?": "Move {name} ({kind}) to the trash?",
+
+ // --- Boites de dialogue ------------------------------------------------
+ "Lecture": "Read",
+ "Écriture": "Write",
+ "Nom": "Name",
+ "Renommer": "Rename",
+ "Déplacer": "Move",
+ "Destination de {name}.": "Destination for {name}.",
+ "Destination": "Destination",
+ "Partager « {name} »": "Share “{name}”",
+ "Membre": "Member",
+ "Choisir un membre": "Choose a member",
+ "Niveau": "Level",
+ "Expire le": "Expires on",
+ "Autoriser": "Grant",
+ "Accès accordés": "Granted access",
+ "Aucun partage pour ce dossier.": "No shares for this folder.",
+ "Révoquer {email}": "Revoke {email}",
+ "{level} · jusqu'au {date}": "{level} · until {date}",
+ "Aucun autre membre à ajouter.": "No other member to add.",
+
+ // --- Discussion de dossier --------------------------------------------
+ "Compte supprimé": "Deleted account",
+ "Supprimer le message": "Delete message",
+ "Ce message sera retiré du salon pour tout le monde.":
+ "This message will be removed from the room for everyone.",
+ "Membres du dossier": "Folder members",
+ "Membres": "Members",
+ "(vous)": "(you)",
+ "Dernière connexion le {date}": "Last sign-in on {date}",
+ "Jamais connecté": "Never signed in",
+ "Masquer les membres": "Hide members",
+ "Afficher les membres": "Show members",
+ "Discussion · {name}": "Discussion · {name}",
+ "Membres ayant accès à ce dossier": "Members with access to this folder",
+ "Fermer la discussion": "Close discussion",
+ "Aucun message": "No messages",
+ "Lancez la discussion : les membres du dossier verront votre message.":
+ "Start the conversation: folder members will see your message.",
+ "Écrire un message… (Entrée pour envoyer, Maj+Entrée pour retour à la ligne)":
+ "Write a message… (Enter to send, Shift+Enter for a new line)",
+ "Votre message": "Your message",
+
+ // --- Visionneuse -------------------------------------------------------
+ "Lecture impossible.": "Unable to read.",
+ "Ouvrir": "Open",
+ "Le PDF s'ouvre dans un nouvel onglet.": "The PDF opens in a new tab.",
+ "Aperçu indisponible pour ce format.": "Preview unavailable for this format.",
+ "Fichier précédent": "Previous file",
+ "Fichier suivant": "Next file",
+
+ // --- Favoris -----------------------------------------------------------
+ "Les fichiers que vous avez étoilés, tous dossiers confondus.":
+ "The files you starred, across all folders.",
+ "Aucun favori": "No favorites",
+ "Étoilez un fichier dans l'explorateur pour le retrouver ici.":
+ "Star a file in the browser to find it here.",
+
+ // --- Recherche ---------------------------------------------------------
+ "Saisissez au moins deux caractères.": "Enter at least two characters.",
+ "Recherchez par nom dans les dossiers et fichiers auxquels vous avez accès.":
+ "Search by name in the folders and files you can access.",
+ "Terme recherché": "Search term",
+ "facture, rapport…": "invoice, report…",
+ "Rechercher": "Search",
+ "Télécharger {name}": "Download {name}",
+ "Aucun résultat": "No results",
+ "Rien ne correspond à « {q} ».": "Nothing matches “{q}”.",
+
+ // --- Galerie -----------------------------------------------------------
+ "Tout": "All",
+ "Images": "Images",
+ "Vidéos": "Videos",
+ "Audio": "Audio",
+ "Documents": "Documents",
+ "Archives": "Archives",
+ "Autres": "Other",
+ "Parcourez les médias auxquels vous avez accès.": "Browse the media you can access.",
+ "Filtrer par type": "Filter by type",
+ "Aucun média": "No media",
+ "Rien à afficher pour ce filtre.": "Nothing to show for this filter.",
+
+ // --- Corbeille ---------------------------------------------------------
+ "Vider la corbeille": "Empty trash",
+ "Tous les éléments seront définitivement supprimés. Cette action est irréversible.":
+ "All items will be permanently deleted. This action cannot be undone.",
+ "Vider": "Empty",
+ "Supprimer définitivement": "Delete permanently",
+ "Supprimer définitivement {name} ? Cette action est irréversible.":
+ "Permanently delete {name}? This action cannot be undone.",
+ "Les éléments sont définitivement supprimés après {days} jours.":
+ "Items are permanently deleted after {days} days.",
+ "Éléments supprimés récemment.": "Recently deleted items.",
+ "Corbeille vide": "Trash is empty",
+ "Aucun élément supprimé pour le moment.": "No items deleted yet.",
+ "Dossiers supprimés": "Deleted folders",
+ "Fichiers supprimés": "Deleted files",
+ "Supprimé le {date}": "Deleted on {date}",
+ "Restaurer {name}": "Restore {name}",
+ "Supprimer définitivement {name}": "Permanently delete {name}",
+
+ // --- Compte ------------------------------------------------------------
+ "Profil, photo, adresse e-mail et sessions ouvertes.":
+ "Profile, photo, email address and open sessions.",
+ "Identité": "Identity",
+ "Informations affichées dans l'interface.": "Information shown in the interface.",
+ "Prénom": "First name",
+ "Informations enregistrées.": "Information saved.",
+ "Photo de profil": "Profile photo",
+ "Image carrée, format PNG ou JPEG.": "Square image, PNG or JPEG.",
+ "Choisir une image": "Choose an image",
+ "Retirer": "Remove",
+ "Si aucune image n'est définie, vos initiales sont affichées.":
+ "If no image is set, your initials are shown.",
+ "Adresse actuelle : {email}": "Current address: {email}",
+ "Nouvelle adresse": "New address",
+ "Un e-mail de confirmation a été envoyé à la nouvelle adresse.":
+ "A confirmation email has been sent to the new address.",
+ "Demander le changement": "Request change",
+ "Sessions ouvertes": "Open sessions",
+ "Appareils actuellement connectés à votre compte.":
+ "Devices currently connected to your account.",
+ "Aucune session active.": "No active session.",
+ "Appareil inconnu": "Unknown device",
+ "Cette session": "This session",
+ "IP inconnue": "Unknown IP",
+ "vue le {date}": "seen on {date}",
+ "Fermer cette session": "Close this session",
+ "Fermer les autres sessions": "Close other sessions",
+ "Fermer la session": "Close session",
+ "Fermer la session en cours vous déconnectera immédiatement.":
+ "Closing the current session will sign you out immediately.",
+
+ // --- Préférences -------------------------------------------------------
+ "Préférences": "Preferences",
+ "Apparence et langue de l'interface.": "Interface appearance and language.",
+ "Thème": "Theme",
+ "Système": "System",
+ "Clair": "Light",
+ "Sombre": "Dark",
+ "Langue": "Language",
+ "Préférences enregistrées.": "Preferences saved.",
+
+ // --- Administration ----------------------------------------------------
+ "Créer des membres, ajustez leurs quotas et gérez les accès.":
+ "Create members, adjust their quotas and manage access.",
+ "Nouveau membre": "New member",
+ "nom ou e-mail": "name or email",
+ "Aucun membre": "No members",
+ "Inactif": "Inactive",
+ "À changer": "To change",
+ "vu le {date}": "seen on {date}",
+ "jamais connecté": "never signed in",
+ "Modifier": "Edit",
+ "Désactiver": "Deactivate",
+ "Réactiver": "Reactivate",
+ "Réinitialiser le mot de passe": "Reset password",
+ "Mot de passe réinitialisé. Les identifiants ont été envoyés à {email}.":
+ "Password reset. Credentials have been sent to {email}.",
+ "Supprimer le membre": "Delete member",
+ "Supprimer définitivement {email} ainsi que ses fichiers ? Cette action est irréversible.":
+ "Permanently delete {email} and their files? This action cannot be undone.",
+ "Compte créé. Les identifiants ont été envoyés à {email}.":
+ "Account created. Credentials have been sent to {email}.",
+ "Rôle": "Role",
+ "Utilisateur": "User",
+ "Administrateur": "Administrator",
+ "Quota (Go, optionnel)": "Quota (GB, optional)",
+ "Fichier max (Mo)": "Max file (MB)",
+ "Modifier le membre": "Edit member",
+ "Quota (Go)": "Quota (GB)",
+ "Emplacements de stockage": "Storage locations",
+ "Volumes montés utilisés pour stocker les fichiers.":
+ "Mounted volumes used to store files.",
+ "Nouvel emplacement": "New location",
+ "Aucun emplacement": "No locations",
+ "Go utilisés": "GB used",
+ "Identifiant technique": "Technical identifier",
+ "Chemin de montage": "Mount path",
+ "Journal d'activité": "Activity log",
+ "Dernières actions enregistrées.": "Latest recorded actions.",
+ "Filtrer par action": "Filter by action",
+ "Aucune entrée": "No entries",
+ "système": "system",
+ "{value} Go": "{value} GB",
+ "{used} / {quota} Go": "{used} / {quota} GB",
+ "{used} Go utilisés": "{used} GB used",
+};
+
+export type Translate = (source: string, vars?: Record) => string;
+
+export const translate = (
+ language: Language,
+ source: string,
+ vars?: Record,
+): string => {
+ const template = language === "en" ? en[source] ?? source : source;
+ if (!vars) return template;
+ return template.replace(/\{(\w+)\}/g, (match, key: string) =>
+ vars[key] !== undefined ? String(vars[key]) : match,
+ );
+};
+
+interface I18nValue {
+ lang: Language;
+ t: Translate;
+}
+
+const I18nContext = createContext(null);
+
+export const I18nProvider = ({
+ language,
+ children,
+}: {
+ language: Language;
+ children: ReactNode;
+}) => {
+ // La langue est poussee dans le module des que le provider rend : les
+ // formatages (`formatBytes`, `formatDate`) lisent cette valeur partagee, en
+ // dehors de React. L'appel est idempotent.
+ setLanguage(language);
+
+ const t = useCallback(
+ (source, vars) => translate(language, source, vars),
+ [language],
+ );
+
+ const value = useMemo(() => ({ lang: language, t }), [language, t]);
+
+ return {children} ;
+};
+
+export const useI18n = (): I18nValue => {
+ const value = useContext(I18nContext);
+ if (!value) throw new Error("useI18n doit etre utilise dans un I18nProvider.");
+ return value;
+};
diff --git a/frontend/src/lib/locale.ts b/frontend/src/lib/locale.ts
new file mode 100644
index 0000000..dd67990
--- /dev/null
+++ b/frontend/src/lib/locale.ts
@@ -0,0 +1,17 @@
+import type { Language } from "./api";
+
+/**
+ * Langue d'affichage courante, partagee par tout le module (hors composants
+ * React) : formatage des tailles et des dates. Le provider i18n la met a jour
+ * des qu'un utilisateur change de langue dans son compte.
+ */
+let language: Language = "fr";
+
+export const getLanguage = (): Language => language;
+
+export const setLanguage = (next: Language): void => {
+ language = next;
+ if (typeof document !== "undefined") document.documentElement.lang = next;
+};
+
+export const getLocale = (): string => (language === "en" ? "en-US" : "fr-FR");
diff --git a/frontend/src/lib/theme.tsx b/frontend/src/lib/theme.tsx
new file mode 100644
index 0000000..48d694b
--- /dev/null
+++ b/frontend/src/lib/theme.tsx
@@ -0,0 +1,38 @@
+import { useEffect, type ReactNode } from "react";
+import type { Theme } from "./api.js";
+
+const STORAGE_KEY = "cohaise-theme";
+
+const prefersDark = (): boolean =>
+ typeof window !== "undefined" &&
+ window.matchMedia("(prefers-color-scheme: dark)").matches;
+
+const isDark = (theme: Theme): boolean =>
+ theme === "dark" || (theme === "system" && prefersDark());
+
+/**
+ * Applique le theme choisi dans le compte sur la racine du document. Le meme
+ * choix est recopie dans `localStorage` pour que `public/theme.js` reproduise
+ * le rendu des le premier pixel, avant que React ne demarre.
+ */
+export const ThemeProvider = ({ theme, children }: { theme: Theme; children: ReactNode }) => {
+ useEffect(() => {
+ const apply = () => {
+ document.documentElement.classList.toggle("dark", isDark(theme));
+ };
+ apply();
+ try {
+ localStorage.setItem(STORAGE_KEY, theme);
+ } catch {
+ /* stockage indisponible : le rendu reste correct */
+ }
+
+ if (theme !== "system") return undefined;
+ const media = window.matchMedia("(prefers-color-scheme: dark)");
+ const onChange = () => apply();
+ media.addEventListener("change", onChange);
+ return () => media.removeEventListener("change", onChange);
+ }, [theme]);
+
+ return <>{children}>;
+};
diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx
index a97634f..a7f5f42 100644
--- a/frontend/src/main.tsx
+++ b/frontend/src/main.tsx
@@ -1,8 +1,10 @@
-import { StrictMode } from "react";
+import { StrictMode, type ReactNode } from "react";
import { createRoot } from "react-dom/client";
import { BrowserRouter } from "react-router-dom";
import { App } from "./App.js";
-import { SessionProvider } from "./lib/session.js";
+import { SessionProvider, useSession } from "./lib/session.js";
+import { I18nProvider } from "./lib/i18n.js";
+import { ThemeProvider } from "./lib/theme.js";
import { ConfirmProvider } from "./components/confirm.js";
import "./styles/index.css";
@@ -12,13 +14,28 @@ if (!container) {
throw new Error("Element racine introuvable");
}
+/**
+ * Enveloppe les preferences de la session (theme, langue) pour qu'elles
+ * s'appliquent a toute l'application, y compris aux ecrans hors coque.
+ */
+const Providers = ({ children }: { children: ReactNode }) => {
+ const { user } = useSession();
+ return (
+
+
+ {children}
+
+
+ );
+};
+
createRoot(container).render(
-
+
-
+
,
diff --git a/frontend/src/pages/Admin.tsx b/frontend/src/pages/Admin.tsx
index c467498..e6b4751 100644
--- a/frontend/src/pages/Admin.tsx
+++ b/frontend/src/pages/Admin.tsx
@@ -9,6 +9,8 @@ import {
type AuditEntry,
type StorageLocation,
} from "../lib/api.js";
+import { useI18n } from "../lib/i18n.js";
+import { getLocale } from "../lib/locale.js";
import { Alert, Badge, EmptyState, Modal, PageHeader } from "../components/feedback.js";
import { useConfirm } from "../components/confirm.js";
import { IconAction } from "../components/IconAction.js";
@@ -27,7 +29,7 @@ const messageOf = (caught: unknown, fallback: string): string =>
caught instanceof ApiError ? caught.message : fallback;
const toGb = (bytes: number): string =>
- (bytes / GB).toLocaleString("fr-FR", { maximumFractionDigits: 1 });
+ (bytes / GB).toLocaleString(getLocale(), { maximumFractionDigits: 1 });
const StatCard = ({ label, value }: { label: string; value: string }) => (
@@ -39,6 +41,7 @@ const StatCard = ({ label, value }: { label: string; value: string }) => (
);
export const AdminUsers = () => {
+ const { t } = useI18n();
const confirm = useConfirm();
const [users, setUsers] = useState(null);
const [stats, setStats] = useState(null);
@@ -57,7 +60,7 @@ export const AdminUsers = () => {
const { users: list } = await api.adminUsers(term || undefined);
setUsers(list);
} catch (caught) {
- setError(messageOf(caught, "Chargement impossible."));
+ setError(messageOf(caught, t("Chargement impossible.")));
setUsers([]);
}
};
@@ -68,6 +71,7 @@ export const AdminUsers = () => {
.adminStats()
.then(setStats)
.catch(() => undefined);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const toggleActive = async (user: AdminUser) => {
@@ -77,7 +81,7 @@ export const AdminUsers = () => {
await api.adminUpdateUser(user.id, { is_active: !user.is_active });
await load(termRef.current);
} catch (caught) {
- setError(messageOf(caught, "Mise à jour impossible."));
+ setError(messageOf(caught, t("Mise à jour impossible.")));
} finally {
setBusy(null);
}
@@ -89,9 +93,9 @@ export const AdminUsers = () => {
setNotice(null);
try {
await api.adminResetPassword(user.id);
- setNotice(`Mot de passe réinitialisé. Les identifiants ont été envoyés à ${user.email}.`);
+ setNotice(t("Mot de passe réinitialisé. Les identifiants ont été envoyés à {email}.", { email: user.email }));
} catch (caught) {
- setError(messageOf(caught, "Réinitialisation impossible."));
+ setError(messageOf(caught, t("Réinitialisation impossible.")));
} finally {
setBusy(null);
}
@@ -99,14 +103,11 @@ export const AdminUsers = () => {
const removeUser = async (user: AdminUser) => {
const ok = await confirm({
- title: "Supprimer le membre",
- message: (
- <>
- Supprimer définitivement {user.email}{" "}
- ainsi que ses fichiers ? Cette action est irréversible.
- >
- ),
- confirmLabel: "Supprimer",
+ title: t("Supprimer le membre"),
+ message: t("Supprimer définitivement {email} ainsi que ses fichiers ? Cette action est irréversible.", {
+ email: user.email,
+ }),
+ confirmLabel: t("Supprimer"),
tone: "danger",
});
if (!ok) return;
@@ -116,7 +117,7 @@ export const AdminUsers = () => {
await api.adminDeleteUser(user.id);
await load(termRef.current);
} catch (caught) {
- setError(messageOf(caught, "Suppression impossible."));
+ setError(messageOf(caught, t("Suppression impossible.")));
} finally {
setBusy(null);
}
@@ -125,24 +126,27 @@ export const AdminUsers = () => {
return (
}
onClick={() => setCreateOpen(true)}
>
- Nouveau membre
+ {t("Nouveau membre")}
}
toolbar={
<>
{stats ? (
-
-
-
+
+
+
) : null}
@@ -155,15 +159,15 @@ export const AdminUsers = () => {
>
setQ(event.target.value)}
/>
- Filtrer
+ {t("Filtrer")}
>
@@ -178,7 +182,7 @@ export const AdminUsers = () => {
) : users.length === 0 ? (
- } title="Aucun membre" />
+ } title={t("Aucun membre")} />
) : (
{users.map((user) => (
@@ -189,35 +193,40 @@ export const AdminUsers = () => {
{user.first_name} {user.last_name}
{user.role_slug === "admin" ? Admin : null}
- {!user.is_active ? Inactif : null}
- {user.must_change_password ? À changer : null}
+ {!user.is_active ? {t("Inactif")} : null}
+ {user.must_change_password ? {t("À changer")} : null}
- {user.email} · {toGb(user.used_bytes)} / {toGb(user.quota_bytes)} Go ·{" "}
+ {user.email} ·{" "}
+ {t("{used} / {quota} Go", {
+ used: toGb(user.used_bytes),
+ quota: toGb(user.quota_bytes),
+ })}{" "}
+ ·{" "}
{user.last_login_at
- ? `vu le ${formatDate(user.last_login_at)}`
- : "jamais connecté"}
+ ? t("vu le {date}", { date: formatDate(user.last_login_at) })
+ : t("jamais connecté")}
setEdit(user)}>
- Modifier
+ {t("Modifier")}
}
isLoading={busy === user.id}
onClick={() => void toggleActive(user)}
/>
}
isLoading={busy === user.id}
onClick={() => void resetPassword(user)}
/>
}
tone="danger"
isLoading={busy === user.id}
@@ -234,7 +243,7 @@ export const AdminUsers = () => {
onClose={() => setCreateOpen(false)}
onCreated={(email) => {
setCreateOpen(false);
- setNotice(`Compte créé. Les identifiants ont été envoyés à ${email}.`);
+ setNotice(t("Compte créé. Les identifiants ont été envoyés à {email}.", { email }));
void load(termRef.current);
}}
/>
@@ -261,6 +270,7 @@ const CreateUserDialog = ({
onClose: () => void;
onCreated: (email: string) => void;
}) => {
+ const { t } = useI18n();
const [email, setEmail] = useState("");
const [firstName, setFirstName] = useState("");
const [lastName, setLastName] = useState("");
@@ -285,17 +295,17 @@ const CreateUserDialog = ({
});
onCreated(user.email);
} catch (caught) {
- setError(messageOf(caught, "Création impossible."));
+ setError(messageOf(caught, t("Création impossible.")));
} finally {
setBusy(false);
}
};
return (
-
+
- Bienvenue {user?.first_name ?? ""}. Ce mot de passe a été défini par un
- administrateur : choisissez le vôtre.
+ {t("Bienvenue {name}. Ce mot de passe a été défini par un administrateur : choisissez le vôtre.", { name: user?.first_name ?? "" })}
- Changement requis
+ {t("Changement requis")}
- Les autres sessions ouvertes sur ce compte seront fermées.
+ {t("Les autres sessions ouvertes sur ce compte seront fermées.")}
void submit(event)}>
{
onChange={(event) => setCurrent(event.target.value)}
/>
setNext(event.target.value)}
/>
{
/>
{error ? {error} : null}
- Enregistrer
+ {t("Enregistrer")}
{
fullWidth
onClick={() => void logout()}
>
- Se déconnecter
+ {t("Se déconnecter")}
diff --git a/frontend/src/pages/ConfirmEmail.tsx b/frontend/src/pages/ConfirmEmail.tsx
index 77529da..e8b66fa 100644
--- a/frontend/src/pages/ConfirmEmail.tsx
+++ b/frontend/src/pages/ConfirmEmail.tsx
@@ -4,11 +4,13 @@ import { Button, Card, CardContent, CardHeader, CardTitle, Spinner } from "../ui
import { Alert } from "../components/feedback.js";
import { ApiError, api } from "../lib/api.js";
import { useSession } from "../lib/session.js";
+import { useI18n } from "../lib/i18n.js";
export const ConfirmEmail = () => {
const [params] = useSearchParams();
const token = params.get("token") ?? "";
const { refresh } = useSession();
+ const { t } = useI18n();
const [state, setState] = useState<"loading" | "success" | "error">("loading");
const [error, setError] = useState(null);
const started = useRef(false);
@@ -18,7 +20,7 @@ export const ConfirmEmail = () => {
started.current = true;
if (!token) {
setState("error");
- setError("Ce lien est incomplet ou invalide.");
+ setError(t("Ce lien est incomplet ou invalide."));
return;
}
api
@@ -29,7 +31,7 @@ export const ConfirmEmail = () => {
})
.catch((caught: unknown) => {
setState("error");
- setError(caught instanceof ApiError ? caught.message : "Confirmation impossible.");
+ setError(caught instanceof ApiError ? caught.message : t("Confirmation impossible."));
});
}, [token, refresh]);
@@ -48,7 +50,7 @@ export const ConfirmEmail = () => {
CoHaiSe
- Changement d'adresse
+ {t("Changement d'adresse")}
@@ -56,7 +58,7 @@ export const ConfirmEmail = () => {
- Confirmation
+ {t("Confirmation")}
{state === "loading" ? (
@@ -65,10 +67,10 @@ export const ConfirmEmail = () => {
) : state === "success" ? (
<>
- Votre adresse e-mail a été mise à jour.
+ {t("Votre adresse e-mail a été mise à jour.")}
- Accéder à mes fichiers
+ {t("Accéder à mes fichiers")}
>
@@ -77,7 +79,7 @@ export const ConfirmEmail = () => {
{error}
- Mon compte
+ {t("Mon compte")}
>
diff --git a/frontend/src/pages/Favorites.tsx b/frontend/src/pages/Favorites.tsx
index 5b6ca1b..7334787 100644
--- a/frontend/src/pages/Favorites.tsx
+++ b/frontend/src/pages/Favorites.tsx
@@ -6,8 +6,10 @@ import { MediaViewer } from "../components/MediaViewer.js";
import { MediaThumb } from "../components/MediaThumb.js";
import { IconAction } from "../components/IconAction.js";
import { DownloadIcon, FolderIcon, StarIcon } from "../components/icons.js";
+import { useI18n } from "../lib/i18n.js";
export const Favorites = () => {
+ const { t } = useI18n();
const [files, setFiles] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
@@ -22,7 +24,7 @@ export const Favorites = () => {
setError(null);
})
.catch((caught: unknown) => {
- setError(caught instanceof ApiError ? caught.message : "Chargement impossible.");
+ setError(caught instanceof ApiError ? caught.message : t("Chargement impossible."));
setFiles([]);
})
.finally(() => setLoading(false));
@@ -34,15 +36,15 @@ export const Favorites = () => {
await api.starFile(file.id);
setFiles((previous) => previous.filter((item) => item.id !== file.id));
} catch (caught) {
- setError(caught instanceof ApiError ? caught.message : "Action impossible.");
+ setError(caught instanceof ApiError ? caught.message : t("Action impossible."));
}
};
return (
{error ? {error} : null}
@@ -54,8 +56,8 @@ export const Favorites = () => {
) : files.length === 0 ? (
}
- title="Aucun favori"
- description="Étoilez un fichier dans l'explorateur pour le retrouver ici."
+ title={t("Aucun favori")}
+ description={t("Étoilez un fichier dans l'explorateur pour le retrouver ici.")}
/>
) : (
@@ -65,7 +67,7 @@ export const Favorites = () => {
type="button"
onClick={() => setViewer(index)}
className="flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-sm border border-border bg-surface-muted text-muted-foreground transition-colors hover:border-border-strong focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
- aria-label={`Aperçu de ${file.name}`}
+ aria-label={t("Aperçu de {name}", { name: file.name })}
>
@@ -75,14 +77,14 @@ export const Favorites = () => {
- {file.folder_name ?? "Racine"}
+ {file.folder_name ?? t("Racine")}
{formatBytes(file.size_bytes)}
}
onClick={() => void unstar(file)}
/>
@@ -93,7 +95,7 @@ export const Favorites = () => {
className="inline-flex h-8 items-center gap-1.5 rounded-sm border border-border-strong bg-surface px-3 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-foreground transition-colors hover:bg-surface-hover"
>
- Télécharger
+ {t("Télécharger")}
))}
diff --git a/frontend/src/pages/ForgotPassword.tsx b/frontend/src/pages/ForgotPassword.tsx
index fd832eb..0a8159f 100644
--- a/frontend/src/pages/ForgotPassword.tsx
+++ b/frontend/src/pages/ForgotPassword.tsx
@@ -3,8 +3,10 @@ import { Link } from "react-router-dom";
import { Button, Card, CardContent, CardDescription, CardHeader, CardTitle, Input } from "../ui/index.js";
import { Alert } from "../components/feedback.js";
import { ApiError, api } from "../lib/api.js";
+import { useI18n } from "../lib/i18n.js";
export const ForgotPassword = () => {
+ const { t } = useI18n();
const [email, setEmail] = useState("");
const [sent, setSent] = useState(false);
const [error, setError] = useState(null);
@@ -18,7 +20,7 @@ export const ForgotPassword = () => {
await api.forgotPassword(email);
setSent(true);
} catch (caught) {
- setError(caught instanceof ApiError ? caught.message : "Demande impossible.");
+ setError(caught instanceof ApiError ? caught.message : t("Demande impossible."));
} finally {
setBusy(false);
}
@@ -39,7 +41,7 @@ export const ForgotPassword = () => {
CoHaiSe
- Mot de passe oublié
+ {t("Mot de passe oublié")}
@@ -47,23 +49,22 @@ export const ForgotPassword = () => {
- Réinitialisation
+ {t("Réinitialisation")}
- Nous vous enverrons un lien valable une heure.
+ {t("Nous vous enverrons un lien valable une heure.")}
{sent ? (
- Si cette adresse correspond à un compte, un message contenant le lien de
- réinitialisation vient d'être envoyé.
+ {t("Si cette adresse correspond à un compte, un message contenant le lien de réinitialisation vient d'être envoyé.")}
- Retour à la connexion
+ {t("Retour à la connexion")}
) : (
@@ -72,7 +73,7 @@ export const ForgotPassword = () => {
onSubmit={(event) => void submit(event)}
>
{
/>
{error ? {error} : null}
- Envoyer le lien
+ {t("Envoyer le lien")}
- Retour à la connexion
+ {t("Retour à la connexion")}
)}
diff --git a/frontend/src/pages/Gallery.tsx b/frontend/src/pages/Gallery.tsx
index 179b4c7..731bf10 100644
--- a/frontend/src/pages/Gallery.tsx
+++ b/frontend/src/pages/Gallery.tsx
@@ -5,6 +5,7 @@ import { Alert, EmptyState, PageHeader } from "../components/feedback.js";
import { MediaViewer } from "../components/MediaViewer.js";
import { MediaThumb } from "../components/MediaThumb.js";
import { ImageIcon } from "../components/icons.js";
+import { useI18n } from "../lib/i18n.js";
const KINDS = [
{ value: "", label: "Tout" },
@@ -19,6 +20,7 @@ const KINDS = [
const PAGE = 60;
export const Gallery = () => {
+ const { t } = useI18n();
const [kind, setKind] = useState("image");
const [items, setItems] = useState([]);
const [loading, setLoading] = useState(true);
@@ -35,7 +37,7 @@ export const Gallery = () => {
setError(null);
})
.catch((caught: unknown) => {
- setError(caught instanceof ApiError ? caught.message : "Chargement impossible.");
+ setError(caught instanceof ApiError ? caught.message : t("Chargement impossible."));
setItems([]);
})
.finally(() => setLoading(false));
@@ -48,7 +50,7 @@ export const Gallery = () => {
const { items: more } = await api.gallery(kind, PAGE, items.length);
setItems((previous) => [...previous, ...more]);
} catch (caught) {
- setError(caught instanceof ApiError ? caught.message : "Chargement impossible.");
+ setError(caught instanceof ApiError ? caught.message : t("Chargement impossible."));
} finally {
setLoadingMore(false);
}
@@ -57,10 +59,10 @@ export const Gallery = () => {
return (
+
{KINDS.map((option) => (
{
: "border-border-control text-muted-foreground hover:bg-surface-hover hover:text-foreground",
)}
>
- {option.label}
+ {t(option.label)}
))}
@@ -94,8 +96,8 @@ export const Gallery = () => {
) : items.length === 0 ? (
}
- title="Aucun média"
- description="Rien à afficher pour ce filtre."
+ title={t("Aucun média")}
+ description={t("Rien à afficher pour ce filtre.")}
/>
) : (
<>
@@ -131,7 +133,7 @@ export const Gallery = () => {
{items.length >= PAGE ? (
void loadMore()}>
- Charger plus
+ {t("Charger plus")}
) : null}
diff --git a/frontend/src/pages/Login.tsx b/frontend/src/pages/Login.tsx
index f5e09de..4937b31 100644
--- a/frontend/src/pages/Login.tsx
+++ b/frontend/src/pages/Login.tsx
@@ -3,9 +3,11 @@ import { Link, Navigate, useNavigate } from "react-router-dom";
import { Button, Card, CardContent, CardDescription, CardHeader, CardTitle, Input } from "../ui/index.js";
import { ApiError, api } from "../lib/api.js";
import { useSession } from "../lib/session.js";
+import { useI18n } from "../lib/i18n.js";
export const Login = () => {
const { user, setUser } = useSession();
+ const { t } = useI18n();
const navigate = useNavigate();
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
@@ -23,7 +25,7 @@ export const Login = () => {
setUser(current);
navigate(current.must_change_password ? "/change-password" : "/files", { replace: true });
} catch (caught) {
- setError(caught instanceof ApiError ? caught.message : "Connexion impossible.");
+ setError(caught instanceof ApiError ? caught.message : t("Connexion impossible."));
} finally {
setBusy(false);
}
@@ -49,19 +51,19 @@ export const Login = () => {
- Connectez-vous pour accéder à vos fichiers.
+ {t("Connectez-vous pour accéder à vos fichiers.")}
- Connexion
- Votre session reste ouverte 14 jours.
+ {t("Connexion")}
+ {t("Votre session reste ouverte 14 jours.")}
void submit(event)}>
{
onChange={(event) => setEmail(event.target.value)}
/>
{
/>
- Se connecter
+ {t("Se connecter")}
@@ -91,7 +93,7 @@ export const Login = () => {
to="/forgot-password"
className="underline-offset-2 hover:text-foreground hover:underline"
>
- Mot de passe oublié ?
+ {t("Mot de passe oublié ?")}
diff --git a/frontend/src/pages/Profile.tsx b/frontend/src/pages/Profile.tsx
index 0693c19..c7a4282 100644
--- a/frontend/src/pages/Profile.tsx
+++ b/frontend/src/pages/Profile.tsx
@@ -1,13 +1,26 @@
import { useEffect, useRef, useState, type FormEvent } from "react";
import { Button, Card, CardContent, CardDescription, CardHeader, CardTitle, Input, Spinner } from "../ui/index.js";
-import { ApiError, api, formatDate, type SessionInfo } from "../lib/api.js";
+import { ApiError, api, formatDate, type Language, type SessionInfo, type Theme } from "../lib/api.js";
import { useSession } from "../lib/session.js";
+import { useI18n } from "../lib/i18n.js";
import { Alert, Badge, PageHeader } from "../components/feedback.js";
import { useConfirm } from "../components/confirm.js";
import { TrashIcon } from "../components/icons.js";
+const THEMES: { value: Theme; label: string }[] = [
+ { value: "system", label: "Système" },
+ { value: "light", label: "Clair" },
+ { value: "dark", label: "Sombre" },
+];
+
+const LANGUAGES: { value: Language; label: string }[] = [
+ { value: "fr", label: "Français" },
+ { value: "en", label: "English" },
+];
+
export const Profile = () => {
const { user, refresh } = useSession();
+ const { t } = useI18n();
const confirm = useConfirm();
const [firstName, setFirstName] = useState(user?.first_name ?? "");
@@ -16,7 +29,12 @@ export const Profile = () => {
const [profileError, setProfileError] = useState(null);
const [savingProfile, setSavingProfile] = useState(false);
- const [avatarNonce, setAvatarNonce] = useState(0);
+ const [theme, setTheme] = useState(user?.theme ?? "system");
+ const [language, setLanguage] = useState(user?.language ?? "fr");
+ const [prefMessage, setPrefMessage] = useState(null);
+ const [prefError, setPrefError] = useState(null);
+ const [savingPrefs, setSavingPrefs] = useState(false);
+
const [avatarError, setAvatarError] = useState(null);
const avatarInput = useRef(null);
@@ -34,6 +52,8 @@ export const Profile = () => {
if (user) {
setFirstName((current) => (current === "" ? user.first_name : current));
setLastName((current) => (current === "" ? user.last_name : current));
+ setTheme(user.theme);
+ setLanguage(user.language);
}
}, [user]);
@@ -43,13 +63,14 @@ export const Profile = () => {
const { sessions: list } = await api.sessions();
setSessions(list);
} catch (caught) {
- setSessionsError(caught instanceof ApiError ? caught.message : "Chargement impossible.");
+ setSessionsError(caught instanceof ApiError ? caught.message : t("Chargement impossible."));
setSessions([]);
}
};
useEffect(() => {
void loadSessions();
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const saveProfile = async (event: FormEvent) => {
@@ -60,14 +81,30 @@ export const Profile = () => {
try {
await api.updateProfile(firstName.trim(), lastName.trim());
await refresh();
- setProfileMessage("Informations enregistrées.");
+ setProfileMessage(t("Informations enregistrées."));
} catch (caught) {
- setProfileError(caught instanceof ApiError ? caught.message : "Enregistrement impossible.");
+ setProfileError(caught instanceof ApiError ? caught.message : t("Enregistrement impossible."));
} finally {
setSavingProfile(false);
}
};
+ const savePreferences = async (event: FormEvent) => {
+ event.preventDefault();
+ setSavingPrefs(true);
+ setPrefError(null);
+ setPrefMessage(null);
+ try {
+ await api.updatePreferences(theme, language);
+ await refresh();
+ setPrefMessage(t("Préférences enregistrées."));
+ } catch (caught) {
+ setPrefError(caught instanceof ApiError ? caught.message : t("Enregistrement impossible."));
+ } finally {
+ setSavingPrefs(false);
+ }
+ };
+
const requestEmail = async (event: FormEvent) => {
event.preventDefault();
setSendingEmail(true);
@@ -77,9 +114,9 @@ export const Profile = () => {
await api.requestEmailChange(password, newEmail.trim());
setPassword("");
setNewEmail("");
- setEmailMessage("Un e-mail de confirmation a été envoyé à la nouvelle adresse.");
+ setEmailMessage(t("Un e-mail de confirmation a été envoyé à la nouvelle adresse."));
} catch (caught) {
- setEmailError(caught instanceof ApiError ? caught.message : "Demande impossible.");
+ setEmailError(caught instanceof ApiError ? caught.message : t("Demande impossible."));
} finally {
setSendingEmail(false);
}
@@ -90,10 +127,9 @@ export const Profile = () => {
setAvatarError(null);
try {
await api.uploadAvatar(file);
- setAvatarNonce((value) => value + 1);
await refresh();
} catch (caught) {
- setAvatarError(caught instanceof ApiError ? caught.message : "Envoi impossible.");
+ setAvatarError(caught instanceof ApiError ? caught.message : t("Envoi impossible."));
} finally {
if (avatarInput.current) avatarInput.current.value = "";
}
@@ -103,19 +139,18 @@ export const Profile = () => {
setAvatarError(null);
try {
await api.deleteAvatar();
- setAvatarNonce((value) => value + 1);
await refresh();
} catch (caught) {
- setAvatarError(caught instanceof ApiError ? caught.message : "Suppression impossible.");
+ setAvatarError(caught instanceof ApiError ? caught.message : t("Suppression impossible."));
}
};
const revokeSession = async (session: SessionInfo) => {
if (session.current) {
const ok = await confirm({
- title: "Fermer la session",
- message: "Fermer la session en cours vous déconnectera immédiatement.",
- confirmLabel: "Fermer",
+ title: t("Fermer la session"),
+ message: t("Fermer la session en cours vous déconnectera immédiatement."),
+ confirmLabel: t("Fermer"),
});
if (!ok) return;
}
@@ -129,7 +164,7 @@ export const Profile = () => {
}
setSessions((previous) => (previous ?? []).filter((item) => item.id !== session.id));
} catch (caught) {
- setSessionsError(caught instanceof ApiError ? caught.message : "Révocation impossible.");
+ setSessionsError(caught instanceof ApiError ? caught.message : t("Révocation impossible."));
} finally {
setRevoking(null);
}
@@ -141,7 +176,7 @@ export const Profile = () => {
await api.revokeOtherSessions();
setSessions((previous) => (previous ?? []).filter((item) => item.current));
} catch (caught) {
- setSessionsError(caught instanceof ApiError ? caught.message : "Révocation impossible.");
+ setSessionsError(caught instanceof ApiError ? caught.message : t("Révocation impossible."));
}
};
@@ -155,25 +190,78 @@ export const Profile = () => {
return (
-
+
+
+
+
+
+ {t("Préférences")}
+ {t("Apparence et langue de l'interface.")}
+
+
+ void savePreferences(event)}>
+
+
+
+
+ {prefError ? {prefError} : null}
+ {prefMessage ? {prefMessage} : null}
+
+
+ {t("Enregistrer")}
+
+
+
+
+
- Identité
- Informations affichées dans l'interface.
+ {t("Identité")}
+ {t("Informations affichées dans l'interface.")}
void saveProfile(event)}>
setFirstName(event.target.value)}
/>
{
{profileMessage ? {profileMessage} : null}
- Enregistrer
+ {t("Enregistrer")}
@@ -193,14 +281,14 @@ export const Profile = () => {
- Photo de profil
- Image carrée, format PNG ou JPEG.
+ {t("Photo de profil")}
+ {t("Image carrée, format PNG ou JPEG.")}
{
@@ -218,14 +306,14 @@ export const Profile = () => {
/>
avatarInput.current?.click()}>
- Choisir une image
+ {t("Choisir une image")}
void removeAvatar()}>
- Retirer
+ {t("Retirer")}
- Si aucune image n'est définie, vos initiales sont affichées.
+ {t("Si aucune image n'est définie, vos initiales sont affichées.")}
@@ -235,21 +323,21 @@ export const Profile = () => {
- Adresse e-mail
- Adresse actuelle : {user.email}
+ {t("Adresse e-mail")}
+ {t("Adresse actuelle : {email}", { email: user.email })}
void requestEmail(event)}>
setNewEmail(event.target.value)}
/>
{
{emailMessage ? {emailMessage} : null}
- Demander le changement
+ {t("Demander le changement")}
-
+
- Sessions ouvertes
- Appareils actuellement connectés à votre compte.
+ {t("Sessions ouvertes")}
+ {t("Appareils actuellement connectés à votre compte.")}
{sessionsError ? {sessionsError} : null}
@@ -280,7 +368,7 @@ export const Profile = () => {
) : sessions.length === 0 ? (
- Aucune session active.
+ {t("Aucune session active.")}
) : (
{sessions.map((session) => (
@@ -288,17 +376,18 @@ export const Profile = () => {
- {session.user_agent ? session.user_agent.slice(0, 60) : "Appareil inconnu"}
+ {session.user_agent ? session.user_agent.slice(0, 60) : t("Appareil inconnu")}
- {session.current ? Cette session : null}
+ {session.current ? {t("Cette session")} : null}
- {session.ip_address ?? "IP inconnue"} · vue le {formatDate(session.last_seen_at)}
+ {session.ip_address ?? t("IP inconnue")} ·{" "}
+ {t("vue le {date}", { date: formatDate(session.last_seen_at) })}
void revokeSession(session)}
className="inline-flex h-8 w-8 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:text-destructive disabled:opacity-50"
@@ -317,11 +406,12 @@ export const Profile = () => {
disabled={sessions === null || sessions.length <= 1}
onClick={() => void revokeOthers()}
>
- Fermer les autres sessions
+ {t("Fermer les autres sessions")}
+
);
};
diff --git a/frontend/src/pages/ResetPassword.tsx b/frontend/src/pages/ResetPassword.tsx
index 572ab63..dd0d1aa 100644
--- a/frontend/src/pages/ResetPassword.tsx
+++ b/frontend/src/pages/ResetPassword.tsx
@@ -3,8 +3,10 @@ import { Link, useSearchParams } from "react-router-dom";
import { Button, Card, CardContent, CardDescription, CardHeader, CardTitle, Input } from "../ui/index.js";
import { Alert } from "../components/feedback.js";
import { ApiError, api } from "../lib/api.js";
+import { useI18n } from "../lib/i18n.js";
export const ResetPassword = () => {
+ const { t } = useI18n();
const [params] = useSearchParams();
const token = params.get("token") ?? "";
const [password, setPassword] = useState("");
@@ -16,7 +18,7 @@ export const ResetPassword = () => {
const submit = async (event: FormEvent) => {
event.preventDefault();
if (password !== confirm) {
- setError("Les deux mots de passe ne correspondent pas.");
+ setError(t("Les deux mots de passe ne correspondent pas."));
return;
}
setBusy(true);
@@ -25,7 +27,7 @@ export const ResetPassword = () => {
await api.resetPassword(token, password);
setDone(true);
} catch (caught) {
- setError(caught instanceof ApiError ? caught.message : "Réinitialisation impossible.");
+ setError(caught instanceof ApiError ? caught.message : t("Réinitialisation impossible."));
} finally {
setBusy(false);
}
@@ -46,7 +48,7 @@ export const ResetPassword = () => {
CoHaiSe
- Nouveau mot de passe
+ {t("Nouveau mot de passe")}
@@ -54,46 +56,46 @@ export const ResetPassword = () => {
- Réinitialisation
- Choisissez un mot de passe robuste.
+ {t("Réinitialisation")}
+ {t("Choisissez un mot de passe robuste.")}
{!token ? (
- Ce lien est incomplet ou invalide.
+ {t("Ce lien est incomplet ou invalide.")}
- Demander un nouveau lien
+ {t("Demander un nouveau lien")}
) : done ? (
- Votre mot de passe a été réinitialisé. Vous pouvez vous connecter.
+ {t("Votre mot de passe a été réinitialisé. Vous pouvez vous connecter.")}
- Se connecter
+ {t("Se connecter")}
) : (
void submit(event)}>
setPassword(event.target.value)}
/>
{
/>
{error ? {error} : null}
- Réinitialiser
+ {t("Réinitialiser")}
)}
diff --git a/frontend/src/pages/Search.tsx b/frontend/src/pages/Search.tsx
index b05ff4b..fb0a6da 100644
--- a/frontend/src/pages/Search.tsx
+++ b/frontend/src/pages/Search.tsx
@@ -3,6 +3,7 @@ import { Button, Input, Spinner } from "../ui/index.js";
import { ApiError, api, formatBytes, type Folder, type UploadedFile } from "../lib/api.js";
import { Alert, EmptyState, PageHeader } from "../components/feedback.js";
import { DownloadIcon, FileIcon, FolderIcon, SearchIcon } from "../components/icons.js";
+import { useI18n } from "../lib/i18n.js";
interface Results {
folders: Folder[];
@@ -10,6 +11,7 @@ interface Results {
}
export const Search = () => {
+ const { t } = useI18n();
const [q, setQ] = useState("");
const [results, setResults] = useState(null);
const [loading, setLoading] = useState(false);
@@ -19,7 +21,7 @@ export const Search = () => {
event.preventDefault();
const query = q.trim();
if (query.length < 2) {
- setError("Saisissez au moins deux caractères.");
+ setError(t("Saisissez au moins deux caractères."));
return;
}
setLoading(true);
@@ -28,7 +30,7 @@ export const Search = () => {
const { folders, files } = await api.search(query);
setResults({ folders, files });
} catch (caught) {
- setError(caught instanceof ApiError ? caught.message : "Recherche impossible.");
+ setError(caught instanceof ApiError ? caught.message : t("Recherche impossible."));
setResults(null);
} finally {
setLoading(false);
@@ -40,16 +42,16 @@ export const Search = () => {
return (
void submit(event)}>
setQ(event.target.value)}
/>
@@ -60,7 +62,7 @@ export const Search = () => {
isLoading={loading}
iconLeading={ }
>
- Rechercher
+ {t("Rechercher")}
}
@@ -75,15 +77,15 @@ export const Search = () => {
) : results === null ? null : total === 0 ? (
}
- title="Aucun résultat"
- description={`Rien ne correspond à « ${q.trim()} ».`}
+ title={t("Aucun résultat")}
+ description={t("Rien ne correspond à « {q} ».", { q: q.trim() })}
/>
) : (