formatjs / formatjs

The monorepo home to all of the FormatJS related libraries, most notably react-intl.

Home Page:https://formatjs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FormattedNumber output when using percentages has an inappropriate default scale

samkelleher opened this issue · comments

Which package?

intl-messageformat-parser

Describe the bug

An input number of 25 is formatted as 2,500% instead of 25% because, for some reason, the scale is defaulting to 100. In the examples as per the spec, the default scale is 1. The multiplier would only be added if explicitly defined. Additionally, adding a scale/1 directive doesn't do anything.

See Also

165429690-5b998593-1ff7-457a-97e8-76c9c402a28d

Why {value, number, ::percent} applies scale/100 by default?

Originally posted by @ZerdoX-x in #1072 (comment)

Relates to:

can u provide a codesandbox?

in my PR #4315 which introduces a live icu editor, you can see the default scale is 100

image

hmm the default scale is basically the ECMA-402 behavior, which conflicts with ICU. This unfortunately is a breaking change so I'm kinda reluctant to fix it.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.