diff --git a/app/components/DocumentViews.tsx b/app/components/DocumentViews.tsx index 21e1c025f..8d1e0f28d 100644 --- a/app/components/DocumentViews.tsx +++ b/app/components/DocumentViews.tsx @@ -1,14 +1,15 @@ -import { compact } from "lodash"; +import compact from "lodash/compact"; import sortBy from "lodash/sortBy"; import { observer } from "mobx-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; -import { dateToRelative } from "@shared/utils/date"; +import { dateLocale, dateToRelative } from "@shared/utils/date"; import Document from "~/models/Document"; import User from "~/models/User"; import Avatar from "~/components/Avatar"; import ListItem from "~/components/List/Item"; import PaginatedList from "~/components/PaginatedList"; +import useCurrentUser from "~/hooks/useCurrentUser"; import useStores from "~/hooks/useStores"; type Props = { @@ -19,6 +20,9 @@ type Props = { function DocumentViews({ document, isOpen }: Props) { const { t } = useTranslation(); const { views, presence } = useStores(); + const user = useCurrentUser(); + const locale = dateLocale(user.language); + const documentPresence = presence.get(document.id); const documentPresenceArray = documentPresence ? Array.from(documentPresence.values()) @@ -53,9 +57,13 @@ function DocumentViews({ document, isOpen }: Props) { ? isEditing ? t("Currently editing") : t("Currently viewing") - : t("Viewed {{ timeAgo }} ago", { + : t("Viewed {{ timeAgo }}", { timeAgo: dateToRelative( - view ? Date.parse(view.lastViewedAt) : new Date() + view ? Date.parse(view.lastViewedAt) : new Date(), + { + addSuffix: true, + locale, + } ), }); return ( diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index 57998812d..52c31eff4 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -168,7 +168,7 @@ "Creating a template from {{titleWithDefault}} is a non-destructive action – we'll make a copy of the document and turn it into a template that can be used as a starting point for new documents.": "Creating a template from {{titleWithDefault}} is a non-destructive action – we'll make a copy of the document and turn it into a template that can be used as a starting point for new documents.", "Currently editing": "Currently editing", "Currently viewing": "Currently viewing", - "Viewed {{ timeAgo }} ago": "Viewed {{ timeAgo }} ago", + "Viewed {{ timeAgo }}": "Viewed {{ timeAgo }}", "Copy of {{ documentName }}": "Copy of {{ documentName }}", "Title": "Title", "Include nested documents": "Include nested documents", @@ -948,7 +948,6 @@ "Online now": "Online now", "Online {{ timeAgo }}": "Online {{ timeAgo }}", "Viewed just now": "Viewed just now", - "Viewed {{ timeAgo }}": "Viewed {{ timeAgo }}", "You updated {{ timeAgo }}": "You updated {{ timeAgo }}", "{{ user }} updated {{ timeAgo }}": "{{ user }} updated {{ timeAgo }}", "You created {{ timeAgo }}": "You created {{ timeAgo }}",