Translation
This commit is contained in:
parent
1bee242d8e
commit
a30edae098
3 changed files with 51 additions and 21 deletions
|
|
@ -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"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue