-
-
Notifications
You must be signed in to change notification settings - Fork 36
Design document for percent formatting #1068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This document is focused for now on documenting the options.
|
||
#### Use a dedicated `:percent` function | ||
|
||
Use a new function `:percent` dedicated to percentages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider names besides :percent
?
The function could apply to all dimensionless units including permille, permillion, perbillion, etc.
For example: {$var :dimensionless unit=permillion}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider other names. I'll add that option.
I'm not wild about unit=percent
(mille, billion, etc. etc.). It's verbose and the other uses seems rare. Really only percent and permille are backed by CLDR data. The others strike me as special uses for unit or number formatting.
exploration/percent-format.md
Outdated
#### Scaling | ||
Implementation always scales the number. The value `0.5` formats as `50%` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we go with the "always scales" approach, :unit
can still be used to not scale.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A first pass. I don't agree with the currently proposed design, but let's first get the available options better presented.
It would be nice to have more example code for the options.
Implementation automatically does (or does not) scale. | ||
There is an option to switch to the other behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation automatically does (or does not) scale. | |
There is an option to switch to the other behavior. | |
Formatter automatically does (or does not) scale. | |
There is an option to switch to the other behavior. | |
The option here may be: | |
- An option `scaling` with boolean values `true` and `false`. | |
- An option `scale` with a small set of supported integer values, possibly only `1` and `100`. |
- Allow `unit=percent` in `:unit` that is identical to `:percent` in formatting performance, | ||
for compatibility with CLDR units, | ||
but document that this usage is not preferred. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this mean that :unit unit=percent
would or would not apply scaling? And why do we need or benefit from compatibility with CLDR units here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need or benefit from compatibility with CLDR units here?
We don't have to be compatible, except that currently the definition of the unit
option values is completely delegated to the unit identifiers found here in TR35. It would be unfortunate to say "unit identifiers except this one specific one"
Would this mean that :unit unit=percent would or would not apply scaling?
That's a good question. In the most recent WG discussion, there was a sentiment that we should make them behave identically to avoid confusion. There's an equal sentiment that they should be opposite each other (for utility). Here I'm trying to express equivalent performance without binding to a specific scaling/not-scaling choice (since that is separate).
Co-authored-by: Eemeli Aro <[email protected]>
Co-authored-by: Eemeli Aro <[email protected]>
Co-authored-by: Eemeli Aro <[email protected]>
Co-authored-by: Eemeli Aro <[email protected]>
- Only percent and permille are backed with CLDR data and symbols. | ||
Other scales would impose an implementation burden. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLDR has data for other scales, too, via portion
units.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not really percent/per mille type scaling though, is it?
exploration/percent-format.md
Outdated
{{Completion: {$n :unit unit=percent}.}} | ||
``` | ||
|
||
#### Use `:math multiply` to scale |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note my concern about implementation burden due to having to support a more general function than we actually need.
This document is focused for now on documenting the options.