diff --git a/web/components/answers/other-profile-answers.tsx b/web/components/answers/other-profile-answers.tsx index f756e9d0..97d8f33e 100644 --- a/web/components/answers/other-profile-answers.tsx +++ b/web/components/answers/other-profile-answers.tsx @@ -10,6 +10,7 @@ import {CompassLoadingIndicator} from 'web/components/widgets/loading-indicator' import {UserLink} from 'web/components/widgets/user-link' import {useOtherAnswers} from 'web/hooks/use-other-answers' import {QuestionWithCountType} from 'web/hooks/use-questions' +import {useT} from 'web/lib/locale' import {shortenedFromNow} from 'web/lib/util/shortenedFromNow' export function OtherProfileAnswers(props: { @@ -18,6 +19,7 @@ export function OtherProfileAnswers(props: { className?: string }) { const {question, className} = props + const t = useT() const otherAnswers = useOtherAnswers(question.id) const shownAnswers = otherAnswers?.filter( (a) => a.multiple_choice != null || a.free_response || a.integer, @@ -49,7 +51,7 @@ export function OtherProfileAnswers(props: {
- {shortenedFromNow(otherAnswer.created_time)} + {shortenedFromNow(otherAnswer.created_time, t)}
{ const [edits, setEdits] = useState(undefined) const isClient = useIsClient() + const t = useT() const loadEdits = async () => { const {data} = await run( @@ -61,7 +63,7 @@ export const CommentEditHistoryButton = (props: {comment: Comment}) => { } onClick={() => setShowEditHistory(true)} > - (edited) {isClient && shortenedFromNow(comment.editedTime)} + (edited) {isClient && shortenedFromNow(comment.editedTime, t)} diff --git a/web/components/relative-timestamp.tsx b/web/components/relative-timestamp.tsx index bbc7caad..f2cc0ead 100644 --- a/web/components/relative-timestamp.tsx +++ b/web/components/relative-timestamp.tsx @@ -16,6 +16,8 @@ export function RelativeTimestamp(props: { }) { const {time, className, placement, shortened} = props const isClient = useIsClient() + const {locale} = useLocale() + const t = useT() return ( - {isClient ? shortened ? shortenedFromNow(time) : fromNow(time) : <>} + {isClient ? shortened ? shortenedFromNow(time, t) : fromNow(time, false, t, locale) : <>} ) diff --git a/web/lib/util/shortenedFromNow.ts b/web/lib/util/shortenedFromNow.ts index bd3845f0..b8e34981 100644 --- a/web/lib/util/shortenedFromNow.ts +++ b/web/lib/util/shortenedFromNow.ts @@ -26,7 +26,7 @@ export function shortenedDuration(diff: duration.Duration, t: any = undefined) { for (const unit in units) { if (units[unit] > 0) { - return `${units[unit]}${t(`time.units.${unit}`, unit)}` + return `${units[unit]}${t ? t(`time.units.${unit}`, unit) : unit}` } }