feat(i18n): update plurals support (#433)

This commit is contained in:
Joaquín Sánchez 2022-12-14 16:56:48 +01:00 committed by GitHub
parent 9899cd0661
commit e4b7b8061a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 15 deletions

View file

@ -11,10 +11,12 @@ const humanReadableNumber = (
if (num < 10000)
return useFormatter.format(num)
// show 1 decimal: we cannot use toFixed(1), it is a string
if (num < 1000000)
return `${Math.floor(num / 1000)}${k}`
return `${useFormatter.format(Math.floor(num / 100) / 10)}${k}`
return `${Math.floor(num / 1000000)}${m}`
// show 2 decimals: we cannot use toFixed(2), it is a string
return `${useFormatter.format(Math.floor(num / 10000) / 100)}${m}`
}
export const formattedNumber = (num: number, useFormatter: Intl.NumberFormat = formatter) => {