-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
i18n: remove default granularity values from formatter #13839
Changes from 1 commit
504e62a
0b88142
7dd7d01
08bc98b
b4a8e23
61c23f5
6232d93
9e82306
325d84b
0d3cbc6
8b0fa70
bf94f1d
125a7bd
929ba50
893968b
f11e9f0
1e800ba
d33c2d0
803fcc7
ded8d2c
c064061
749c705
c04d995
55b9a52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,11 +58,16 @@ export class I18n { | |
/** | ||
* Format number. | ||
* @param {number} number | ||
* @param {number=} granularity Number of decimal places to include. Defaults to 0.1. | ||
* @param {number=} granularity Number of decimal places to include. | ||
* If undefined, the number will be displayed in full. | ||
* @return {string} | ||
*/ | ||
formatNumber(number, granularity = 0.1) { | ||
return this._formatNumberWithGranularity(number, granularity); | ||
formatNumber(number, granularity = undefined) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: optional params are already undefined by default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even so, I think having a second way to represent "this is optional" is nice. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm definitely for not including There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I don't think we do this anywhere else. I still prefer without |
||
if (granularity === undefined) { | ||
return new Intl.NumberFormat(this._locale).format(number).replace(' ', NBSP2); | ||
} else { | ||
return this._formatNumberWithGranularity(number, granularity); | ||
} | ||
} | ||
|
||
/** | ||
|
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.
When you say "power of 10" you mean "integer power of 10" right? If so I don't think 0.5 qualifies.
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.
updated but... maybe we could just reduce the restriction on granularity to any positive number?