UnitsNet icon indicating copy to clipboard operation
UnitsNet copied to clipboard

Default number format should be CultureInfo.CurrentCulture, not CurrentUICulture

Open pgrawehr opened this issue 4 years ago • 7 comments

The default formatting of numbers (in QuantityFormatter.cs), when no explicit culture is given, should use CultureInfo.CurrentCulture not CultureInfo.CurrentUICulture. On Windows, the first corresponds to the selection from the control panel "Regional Settings" and defines the locale settings of the user. CurrentUICulture represents the language of the UI, which will be english for everyone that uses Windows in english.

In my case, CurrentUICulture is "de-DE", since my Windows is German, but CurrentCulture is "de-CH", since I use the number format for Switzerland (which is quite different).

pgrawehr avatar May 22 '20 09:05 pgrawehr

Thanks for reporting, you may be right. Will look into it.

angularsen avatar May 25 '20 06:05 angularsen

It is correct, we're using the wrong one. This would be a behavior break though.

tmilnthorp avatar May 26 '20 14:05 tmilnthorp

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 25 '20 19:07 stale[bot]

No, I don't think this should be wontfix. A PR for this is pending (but apparently waiting for other stuff to get done as well)

pgrawehr avatar Jul 26 '20 06:07 pgrawehr

@angularsen @tmilnthorp Are there any plans when 4.X will be branched out so that some of the pending breaking changes could be implemented for 5.0? The number formatting is unfortunately poor, so that I keep doing it manually.

pgrawehr avatar Oct 30 '21 07:10 pgrawehr

@pgrawehr There is #982 now. Would you be interested in doing a PR to that branch?

angularsen avatar Nov 03 '21 07:11 angularsen

I'm quite busy at the moment, but I'll try to adapt #795 for that branch. I also need to check whether there's any leftovers from #788 (such as formatting obtions to remove or improve)

pgrawehr avatar Nov 03 '21 12:11 pgrawehr

If I am not mistaken, this was fixed in v5 by #986.

angularsen avatar Feb 02 '23 22:02 angularsen