Open mahnunchik opened 1 year ago
Any news?
I'm unable to format number like Intl.NumberFormat
can:
const number = '123456.78900000000000001';
console.log(new Intl.NumberFormat('en', { maximumFractionDigits: 20 }).format(number));
// 123,456.78900000000000001
MDN data is outdated https://github.com/mdn/browser-compat-data/issues/18447
hmm 🤔 I would like to support BigInt for NumberFormat, but, vue-i18n uses classic props, which results in a type error. 😭 https://github.com/vuejs/core/issues/5652
Clear and concise description of the problem
Intl.NumberFormat
supportsNumber
,BigInt
, andString
as a number parameter.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/format
Currently only number is supported in
vue-i18n
library: https://github.com/intlify/vue-i18n-next/blob/fa612d336e603cce237491eca092a7e856e4cb6c/packages/vue-i18n-core/src/components/NumberFormat.ts#L44-L47Suggested solution
$n
method should support the same types of parameter as underlyingIntl.NumberFormat.prototype.format()
method.Alternative
No response
Additional context
BigInt
parameter is useful for numbers exceed MAX_SAFE_INT numbersString
parameter is useful for number with many decimals places.Validations