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

Format numbers by their locale #5728

Closed
wants to merge 1 commit into from

Conversation

iAmWillShepherd
Copy link
Contributor

@iAmWillShepherd iAmWillShepherd commented Sep 24, 2018

Fixes #1245

Related issue: electron/electron#9247

I took a shot in the dark on this, but I understand that using the toLocaleString function may not be sufficient, so it would be great if we can discuss the reasons why it's not sufficient or better approaches to formatting large numbers.

Before

screen shot 2018-09-24 at 9 09 34 pm

After

screen shot 2018-09-24 at 3 08 41 pm

cc @desktop/engineering

@shiftkey
Copy link
Member

shiftkey commented Sep 24, 2018

For reference, we talked about this last in #1257 and I think there were two themes about why we left it as-is:

  • I can't recall how macOS does this, but on Windows you can choose a different locale for formatting numbers/dates/currency to the language chosen for the OS, and Desktop doesn't reflect that because browsers and Electron will only use the language in the locale-specific APIs.
  • this is the only place where we show a number that might need formatting, so it wasn't a thing that most users noticed

The work required to understand the domain well enough, to then write a native module to read the locale info from the OS-specific APIs, and finally get enough test coverage of what users might do wasn't quite worth it then.

Maybe if we get more interest in proper date formatting (I'm not sure what Momentjs does here, but I suspect it's limited by browser support too) this could become a more practical investment?

outofambit
outofambit previously approved these changes Oct 1, 2018
Copy link
Contributor

@outofambit outofambit left a comment

Choose a reason for hiding this comment

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

I don't see the harm in doing this. It may not work for all configurations, but its at worst status quo.

@outofambit outofambit self-assigned this Oct 1, 2018
@niik
Copy link
Member

niik commented Oct 2, 2018

I don't see the harm in doing this. It may not work for all configurations, but its at worst status quo.

As @shiftkey said we decided against this approach in #1257 and I'm not sure what's changed since then that would make us reconsider?

If we can get proper number formatting that takes into account the number formatting locale I'd be super happy to merge but unless something has changed that I'm missing here I don't think we have that information at our disposal at the moment.

but its at worst status quo.

Could you elaborate on this? For me it would render the example in the PR body as 6,000 where ',' is the thousand separator used in the US whereas for Swedish it should be a space. Comma is the decimal separator in Swedish.

My locale settings

screen shot 2018-10-02 at 10 25 53

screen shot 2018-10-02 at 10 26 09

What this PR proposes

screen shot 2018-10-02 at 10 26 21

What it should be

screen shot 2018-10-02 at 10 27 35

@outofambit outofambit dismissed their stale review October 2, 2018 16:09

needs more consideration

@outofambit
Copy link
Contributor

thanks @niik that helps a lot to clarify the problem. @iAmWillShepherd do you have thoughts?

@outofambit outofambit removed their assignment Oct 2, 2018
@outofambit
Copy link
Contributor

for what its worth, the following also works

(1234.56).toLocaleString("en-SE")
"1 234,56"

@iAmWillShepherd
Copy link
Contributor Author

@outofambit this hasn't been address in Electron or Chromium(?), so there's not much we can do at the moment. I'm going to close this out until a fix is implemented in our dependencies.

@rafeca rafeca deleted the big-numbers-are-hard-to-read branch July 22, 2020 08:21
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

4 participants