improve formatting using Intl.NumberFormat
This commit is contained in:
		
							parent
							
								
									c35bc2b03f
								
							
						
					
					
						commit
						ee8ecb20de
					
				
							
								
								
									
										1
									
								
								frontend/src/__generated__/locales/en-US.ts
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								frontend/src/__generated__/locales/en-US.ts
									
									
									
										generated
									
									
									
								
							| @ -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`, | ||||
|  | ||||
| @ -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`<span title="${fullFormatter.format(minutes)}">
 | ||||
|         ${compactFormatter.format(minutes)}</span | ||||
|       > | ||||
|       (${humanizeDuration(seconds * 1000)})`;
 | ||||
|   }; | ||||
| 
 | ||||
|   render() { | ||||
|  | ||||
| @ -2458,10 +2458,6 @@ | ||||
| <trans-unit id="sa1bc28260e4221a8"> | ||||
|   <source>Please log in to continue.</source> | ||||
| </trans-unit> | ||||
| <trans-unit id="sb63223f6d06f51d9"> | ||||
|   <source><x id="0" equiv-text="${numberFormatter.format(minutes)}"/> minutes (<x id="1" equiv-text="${humanizeDuration(seconds * 1000)}"/>)</source> | ||||
|   <note from="lit-localize">Execution seconds display, showing an amount of time in minutes as well as, within parentheses, hours, minutes, and seconds.</note> | ||||
| </trans-unit> | ||||
| </body> | ||||
| </file> | ||||
| </xliff> | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user