From a30edae098345ebb1d29f1dd28b00858024522bd Mon Sep 17 00:00:00 2001 From: Arthur Belleville Date: Sat, 25 Oct 2025 21:44:56 +0200 Subject: [PATCH] Translation --- apps/main/src/locales/en/notes.json | 16 +++++++++++- apps/main/src/locales/fr/notes.json | 16 +++++++++++- apps/main/src/pages/notes.tsx | 40 +++++++++++++++-------------- 3 files changed, 51 insertions(+), 21 deletions(-) diff --git a/apps/main/src/locales/en/notes.json b/apps/main/src/locales/en/notes.json index ba06772..9b1b4a2 100644 --- a/apps/main/src/locales/en/notes.json +++ b/apps/main/src/locales/en/notes.json @@ -21,5 +21,19 @@ "hideSidebar": "Hide notes list", "deleteNote": "Delete note", "untitledNote": "Untitled Note", - "clickNewNoteToStart": "Click 'New Note' to get started" + "clickNewNoteToStart": "Click 'New Note' to get started", + "justNow": "Just now", + "minutesAgo": "{{count}}m ago", + "hoursAgo": "{{count}}h ago", + "today": "Today", + "yesterday": "Yesterday", + "daysAgo": "{{count}} days ago", + "daysAgo_one": "{{count}} day ago", + "daysAgo_other": "{{count}} days ago", + "weeksAgo": "{{count}} weeks ago", + "weeksAgo_one": "{{count}} week ago", + "weeksAgo_other": "{{count}} weeks ago", + "monthsAgo": "{{count}} months ago", + "monthsAgo_one": "{{count}} month ago", + "monthsAgo_other": "{{count}} months ago" } diff --git a/apps/main/src/locales/fr/notes.json b/apps/main/src/locales/fr/notes.json index 1623552..f1ec569 100644 --- a/apps/main/src/locales/fr/notes.json +++ b/apps/main/src/locales/fr/notes.json @@ -21,5 +21,19 @@ "hideSidebar": "Masquer la liste des notes", "deleteNote": "Supprimer la note", "untitledNote": "Note sans titre", - "clickNewNoteToStart": "Cliquez sur 'Nouvelle note' pour commencer" + "clickNewNoteToStart": "Cliquez sur 'Nouvelle note' pour commencer", + "justNow": "À l'instant", + "minutesAgo": "Il y a {{count}} minutes", + "hoursAgo": "Il y a {{count}} heures", + "today": "Aujourd'hui", + "yesterday": "Hier", + "daysAgo": "Il y a {{count}} jours", + "daysAgo_one": "Il y a {{count}} jour", + "daysAgo_other": "Il y a {{count}} jours", + "weeksAgo": "Il y a {{count}} semaines", + "weeksAgo_one": "Il y a {{count}} semaine", + "weeksAgo_other": "Il y a {{count}} semaines", + "monthsAgo": "Il y a {{count}} mois", + "monthsAgo_one": "Il y a {{count}} mois", + "monthsAgo_other": "Il y a {{count}} mois" } diff --git a/apps/main/src/pages/notes.tsx b/apps/main/src/pages/notes.tsx index 4cbbea4..6283a07 100644 --- a/apps/main/src/pages/notes.tsx +++ b/apps/main/src/pages/notes.tsx @@ -20,25 +20,6 @@ import { NotesEditor } from "../components/NotesEditor"; import { useCreateNote, useDeleteNote, useNote, useNotes, useUpdateNote } from "../hooks/notes"; import { useNavigate, useParams } from "react-router-dom"; -// Helper function to format dates in a human-readable way -const formatRelativeDate = (date: Date): string => { - const now = new Date(); - const diffInMs = now.getTime() - date.getTime(); - const diffInMinutes = Math.floor(diffInMs / (1000 * 60)); - const diffInHours = Math.floor(diffInMs / (1000 * 60 * 60)); - const diffInDays = Math.floor(diffInMs / (1000 * 60 * 60 * 24)); - - if (diffInMinutes < 1) return "Just now"; - if (diffInMinutes < 60) return `${diffInMinutes}m ago`; - if (diffInHours < 24) return `${diffInHours}h ago`; - if (diffInDays === 0) return "Today"; - if (diffInDays === 1) return "Yesterday"; - if (diffInDays < 7) return `${diffInDays} days ago`; - if (diffInDays < 30) return `${Math.floor(diffInDays / 7)} weeks ago`; - if (diffInDays < 365) return `${Math.floor(diffInDays / 30)} months ago`; - return date.toLocaleDateString(); -}; - const useNoteId = () => { const navigate = useNavigate(); const params = useParams(); @@ -89,6 +70,27 @@ export default function NotesPage({ mode }: { mode: "create" | "edit" }) { setEditorKey((prev) => prev + 1); }, [mode, noteId, notes]); + // Helper function to format dates in a human-readable way + const formatRelativeDate = (date: Date): string => { + const now = new Date(); + const diffInMs = now.getTime() - date.getTime(); + const diffInMinutes = Math.floor(diffInMs / (1000 * 60)); + const diffInHours = Math.floor(diffInMs / (1000 * 60 * 60)); + const diffInDays = Math.floor(diffInMs / (1000 * 60 * 60 * 24)); + + if (diffInMinutes < 1) return t("justNow", "Just now"); + if (diffInMinutes < 60) return t("minutesAgo", "{{count}}m ago", { count: diffInMinutes }); + if (diffInHours < 24) return t("hoursAgo", "{{count}}h ago", { count: diffInHours }); + if (diffInDays === 0) return t("today", "Today"); + if (diffInDays === 1) return t("yesterday", "Yesterday"); + if (diffInDays < 7) return t("daysAgo", "{{count}} days ago", { count: diffInDays }); + if (diffInDays < 30) + return t("weeksAgo", "{{count}} weeks ago", { count: Math.floor(diffInDays / 7) }); + if (diffInDays < 365) + return t("monthsAgo", "{{count}} months ago", { count: Math.floor(diffInDays / 30) }); + return date.toLocaleDateString(); + }; + const handleContentChange = (newContent: string) => { setContent(newContent); setHasUnsavedChanges(true);