From ee8ecb20de8ee9219720351cf1ab23d91eca8f90 Mon Sep 17 00:00:00 2001 From: emma Date: Mon, 13 Nov 2023 18:49:28 -0500 Subject: [PATCH] improve formatting using Intl.NumberFormat --- frontend/src/__generated__/locales/en-US.ts | 1 - frontend/src/pages/org/dashboard.ts | 28 +++++++++++++-------- frontend/xliff/en-US.xlf | 4 --- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/frontend/src/__generated__/locales/en-US.ts b/frontend/src/__generated__/locales/en-US.ts index 172f87c6..f59e3771 100644 --- a/frontend/src/__generated__/locales/en-US.ts +++ b/frontend/src/__generated__/locales/en-US.ts @@ -595,7 +595,6 @@ 's53846234c681dace': `Sorry, couldn't invite user at this time.`, 's63ca31a1df9116e2': str`Successfully removed ${0} from ${1}.`, 's667558910cf30318': str`Sorry, couldn't remove ${0} at this time.`, -'sb63223f6d06f51d9': str`${0} minutes (${1})`, 'sd7cb8be58c9b3603': `Create New...`, 's91c206764e342fbd': `Crawl Workflow`, 's96668830629e0dfc': `Upload`, diff --git a/frontend/src/pages/org/dashboard.ts b/frontend/src/pages/org/dashboard.ts index 247c119f..7742c330 100644 --- a/frontend/src/pages/org/dashboard.ts +++ b/frontend/src/pages/org/dashboard.ts @@ -60,19 +60,27 @@ export class Dashboard extends LiteElement { } private humanizeExecutionSeconds = (seconds: number) => { - const minutes = Math.floor(seconds / 60); + const minutes = Math.ceil(seconds / 60); const locale = getLocale(); - const numberFormatter = new Intl.NumberFormat(locale, {}); + const compactFormatter = new Intl.NumberFormat(locale, { + notation: "compact", + style: "unit", + unit: "minute", + unitDisplay: "long", + }); - return msg( - str`${numberFormatter.format(minutes)} minutes (${humanizeDuration( - seconds * 1000 - )})`, - { - desc: "Execution seconds display, showing an amount of time in minutes as well as, within parentheses, hours, minutes, and seconds.", - } - ); + const fullFormatter = new Intl.NumberFormat(locale, { + style: "unit", + unit: "minute", + unitDisplay: "long", + maximumFractionDigits: 0, + }); + + return html` + ${compactFormatter.format(minutes)} + (${humanizeDuration(seconds * 1000)})`; }; render() { diff --git a/frontend/xliff/en-US.xlf b/frontend/xliff/en-US.xlf index da493f84..85b8ae0d 100644 --- a/frontend/xliff/en-US.xlf +++ b/frontend/xliff/en-US.xlf @@ -2458,10 +2458,6 @@ Please log in to continue. - - minutes () - Execution seconds display, showing an amount of time in minutes as well as, within parentheses, hours, minutes, and seconds. -