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 these numbers so they have the right separator #1257

Closed
wants to merge 1 commit into from

Conversation

shiftkey
Copy link
Member

Fixes #1245

@niik
Copy link
Member

niik commented Apr 21, 2017

This seems to be based on the operating system language rather than the number formatting. I run Windows with Swedish formatting for dates, numbers, etc but English as the primary language.

image

If we are going to format numbers we should respect the system number locale and I'd expect this to read 3 491 on my locale. Comma is a decimal symbol in Swedish and many other nordic countries.

Contrast this to WPF

image

@shiftkey
Copy link
Member Author

shiftkey commented Apr 21, 2017

@niik that's interesting. I'd assumed that the locale stuff would be pre-filled like this de-DE VM is configured for:

And here's the region settings to contrast:

What's different about your setup that I've missed?

EDIT: actually, if the navigator.language is en on your machine do you know browser APIs I should be looking up instead for this number formatting? I gather it's a solved thing for browsers to find these...

@niik
Copy link
Member

niik commented Apr 21, 2017

What's different about your setup that I've missed?

That there's several sub-parts of localization. There's language (I'm running en-US) but there's also number formatting, date formatting, currency etc. I'm running with the English language pack but Swedish formatting for currency, numbers, dates etc.

EDIT: actually, if the navigator.language is en

navigator.language on my machine is en-US.

do you know browser APIs I should be looking up instead for this number formatting? I gather it's a solved thing for browsers to find these...

Javascript supports i18n number formatting through Intl.NumberFormat()

image

That also defaults to the browser language though so one would need to provide the appropriate number locale. I don't know how to get a hold of that from js. Complicating things even further the default formats of a locale can be overridden on Windows so I guess the only way to follow platform conventions would be to pull the information from something like GetNumberFormatEx and construct a NumberFormat based on that.

@joshaber
Copy link
Contributor

https://bugs.chromium.org/p/chromium/issues/detail?id=120473 and https://bugs.chromium.org/p/chromium/issues/detail?id=33413 look like the relevant Chromium bugs. Looks like we'd have to write some native code to make this work and I imagine this is something that should be in Electron proper. I opened electron/electron#9247 to track this on the Electron side.

@shiftkey
Copy link
Member Author

@joshaber @niik is it worth taking this in as a "better than nothing" solution while we figure out the upstream situation?

@niik
Copy link
Member

niik commented Apr 24, 2017

@joshaber @niik is it worth taking this in as a "better than nothing" solution while we figure out the upstream situation?

I'll let @joshaber make the final call on this one but FWIW right now this is actually a step down in usability for me. Say what you want about unformatted integers, they're ubiquitous and well-understood. I'm leaning towards trying to solve this properly.

@joshaber
Copy link
Contributor

joshaber commented Apr 24, 2017

I was planning to defer to @niik, so it sounds like we should wait and Do It Right.

@joshaber joshaber added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Apr 25, 2017
@shiftkey
Copy link
Member Author

🚮

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants