Closed Kirill486 closed 6 years ago
Please, which globalize version are you using?
I use v 1.1.1
Please, test it using 1.4.0-alpha.0
?
1.4.0-alpha.0
is the version where you will find compact support.
Even in newer version this functionality seem not working correctly.
var formatteden = Globalize('en').numberFormatter({compact: "long"})(100000)
undefined
formatteden
"100 thousand"
var parceden = Globalize('en').numberParser({compact: "long"})(formatteden)
undefined
parceden
NaN
And is there a way specify the format (thousands or millions or billions)?
Thanks for checking, reopening then...
I came to conclusion, that normally you wouldn't parse compact numbers(it has a hudge unaccuracy, even billions is an option), it's just worth mentioning in documentation.
Clarifying this issue... Formatting works fine [1], but there's no parsing support for number compact option.
1:
Globalize('en').numberFormatter({compact: "long"})(100000)
// > '100 thousand'
Hi, guys) I spent some time trying to get my number formatted as thousands and millions and billions and so on. This wasn't that much an issue in previous version (0.x.x). I'm about to give up. Could you possibly somehow guide me out? After I faced a failure with the 'compact' option, I went to see number putterns on http://cldr.unicode.org/translation/number-patterns#TOC-Pattern-Characters They don't work either. I tried:
Globalize('en').formatNumber(100000, {style: 'decimal'})
"100,000"
Globalize('en').formatNumber(100000, {raw: '00K'})
"100000K"
Globalize('en').formatNumber(100000, {raw: '#,##0%'})
"10,000,000%"
Globalize('en').formatNumber(100000, {compact: 'short'})
"100,000"
Globalize('en').formatNumber(100000, {compact: 'long'})
"100,000"
Globalize('en').formatNumber(1, {style: 'percent'})
"100%"
This is the only one that work correctly.
What i need is: format my numbers using styles listed in 'decimalFormats' section of the number.json Is that possible?