Skip to content
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

Number formatting using Intl.* APIs #14174

Merged
merged 1,923 commits into from Apr 13, 2023

Conversation

niik
Copy link
Member

@niik niik commented Mar 15, 2022

Closes #1245

Description

Back in 2017 I wrote "I'm leaning towards trying to solve this properly." in response to our first attempt at fixing #1245 (#1257). Now, 5-ish years later technology has finally caught up to where we're able to do this with a relatively small amount of support logic 🎉

Turns out ☝️ was a little bit premature, see #14173 (comment)

This builds upon #14173 and adds region-aware formatting of numbers.

I also took this opportunity to render the number of commits ahead/behind in a compact format (i.e number > 1000 will render as 1K). Hovering will get you the exact number but if you're behind by 1000 or more you likely don't care about the exact number.

There's a good chance I've missed a number of (pun intended) places where we present numbers to the user but that's okay, we can fix that incrementally.

Screenshots

Before en-US en-SE
image image image
image image image

Release notes

Notes: no-notes

@niik niik mentioned this pull request Mar 15, 2022
@tidy-dev tidy-dev self-assigned this Mar 16, 2022
Copy link
Contributor

@tidy-dev tidy-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a little spelling nit. But, also, a place missed is line 654 of compare.tsx for the squashing dialog.

As for it working, I switched my region to Sweden, Spain, and France. It worked as expected for Sweden, but not for Spain or France. But, I figure the is the same issue that Sergio mentioned in slack so I am assuming not something for this PR.

import QuickLRU from 'quick-lru'
import { getFormattingLocales } from './formatting-locale'

// Initializing a nuumber formatter is expensive but formatting is relatively
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Initializing a nuumber formatter is expensive but formatting is relatively
// Initializing a number formatter is expensive but formatting is relatively

@niik niik changed the title Region aware number formatting Number formatting using Intl.* APIs Mar 18, 2022
@niik
Copy link
Member Author

niik commented Mar 18, 2022

So this will also be affected by #14173 (comment).

Given that we're switching to en-US-POSIX by default there will be no number grouping for now.

@sergiou87 @tidy-dev One thing that will change with this PR though is the compact format of commits > 1000. I think that's okay though even though that'll use . as the decimal separator. Our plan is definitely to try and support non-US region formats soon and the number of users pushing/pulling more than 1000 commits should be relatively low.

@niik niik requested a review from tidy-dev March 18, 2022 10:58
Copy link
Contributor

@tidy-dev tidy-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨ Makes sense. :)

tidy-dev and others added 28 commits April 7, 2023 20:18
Bumps [xml2js](https://github.com/Leonidas-from-XIV/node-xml2js) from 0.4.19 to 0.5.0.
- [Release notes](https://github.com/Leonidas-from-XIV/node-xml2js/releases)
- [Commits](Leonidas-from-XIV/node-xml2js@0.4.19...0.5.0)

---
updated-dependencies:
- dependency-name: xml2js
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
as it never had a "Visual Studio" prefix, which is a registered name
Add icons for tabs in Repository settings dialog
Co-authored-by: Markus Olsson <j.markus.olsson@gmail.com>
Add support for VimR code editor on macOS.
…tip-on-checkbox-focus

Open the changed file header tool tip on checkbox focus
Changes and History tab panels are syntaxed as such for screen readers
…ard-accessible

Use toggle tip component for commit summary length hint
Tooltip for Committing Message Avatar is a toggle tip
Undo Confirmation Modal is an Alert Dialog
@niik niik merged commit b80b5ea into locale-aware-formatting Apr 13, 2023
1 of 5 checks passed
@niik niik deleted the region-aware-number-formatting branch April 13, 2023 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet