Skip to content

Conversation

@laanwj
Copy link
Member

@laanwj laanwj commented Mar 18, 2014

  • Change bitcoinamountfield to use locale-specific number format
  • Change bitcoinunits to show and parse locale-specific numbers
  • If a language/territory is selected in options, this is set as default locale (overrides system locale)

Examples:

  • US: 123,456.78 μBTC
  • Dutch: 123.456,78 μBTC
  • German (Switzerland): 123'456.78
    ...

Fixes #3887

@luke-jr
Copy link
Member

luke-jr commented Mar 18, 2014

This is broken. BTC has always intentionally used locale-independent formatting so it is written the same way internationally.

It should always render as: 123,456.78 μBTC

@laanwj
Copy link
Member Author

laanwj commented Mar 18, 2014

Meh. Many people do like it with local formatting. Maybe make the number
locale configurable separately from the language and default to US.

Todo: make sure that this doesn't affect URI amount parsing.

@CydeWeys
Copy link

@luke-jr It doesn't always render as 123,456.78 μBTC though. The issue that I recently filed, #3887, came about because the balance currently renders as 123456789.00 μBTC, which is not very decipherable (it needs some kind of places delimiter).

@luke-jr
Copy link
Member

luke-jr commented Mar 18, 2014

@laanwj Doesn't mean we should accomidate it... Bitcoin should be internationally recognisable. If we do accomidate localised-BTC, by the same logic we should merge TBC support also.

@CydeWeys I agree the commas should be added.

@laanwj
Copy link
Member Author

laanwj commented Mar 19, 2014

@Drak Can you help testing this in whatever locale you're in?

@laanwj
Copy link
Member Author

laanwj commented Mar 19, 2014

@Drak Thanks for testing so quickly!

@BitcoinPullTester there appears to be an issue with Bitcoin URIs. I thought I handled this by always parsing the amounts in the C locale ( https://github.com/bitcoin/bitcoin/pull/3893/files#diff-a459a939be4fe065dd5f64ab60bb30d0R136 ), but something is going wrong. Need to fix this before this can be merged.

@laanwj
Copy link
Member Author

laanwj commented Mar 21, 2014

Ok, Bitcoin URIs work again as they're supposed to. This was sneaky, in Qt <5.0 to the QLocale.toLongLong has a 'base' argument that [in the 'c' locale] defaults to 0 which amounts to 'auto detect base'. '0100000' was interpreted as octal! In Qt>=5.0 the base is always 10.

TODO:

  • add some unit tests for various locale
  • add a GUI option to set the bitcoin amounts locale separately from the default/system locale.

- Change bitcoinamountfield to use locale-specific number format
- Change bitcoinunits to show and parse locale-specific numbers
- If a language/territory is selected in options, this is set as default
  locale (overrides system locale).

Fixes bitcoin#3887
laanwj added 2 commits March 22, 2014 08:00
Tests various locales, as well as variants with and without
decimals group separators.
Embedding UTF-8 in source code is not portable.

Also make unit descriptions translatable.
@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/a8c9ed2ecf40386de5bc93e4796948714e6f2e93 for binaries and test log.
This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/
Contact BlueMatt on freenode if something looks broken.

@laanwj
Copy link
Member Author

laanwj commented Mar 23, 2014

TODO:

  • check fa_IR locale and other locales with non-latin numerals, if I can make no sense of them, exclude them for now

@CydeWeys
Copy link

@laanwj Thanks for all of your hard work. This is going to be an awesome new feature.

@leofidus
Copy link

I agree with @luke-jr on this one. If we want more readable large numbers, using thin spaces as a thousand seperator is a better option imho since it's unambigious between all locales.

Also, how does locale-aware parsing affect me if I use the old format? Say I am a Dutch. So far, entering 1.234 Bitcoins when sending Bitcoins always sent just over one Bitcoin. Would this suddenly send over 1000 Bitcoins with this change?

@laanwj
Copy link
Member Author

laanwj commented Mar 23, 2014

@leofidus No, it will still default to US. However people who want number formatting/parsing in their own locale can do so. Please read my actual posts instead of spreading FUD.

@leofidus
Copy link

@laanwj I am referring to after I changed the setting, but while I am still in the habit of using the old way. I admit that I did not express that clearly.

@laanwj
Copy link
Member Author

laanwj commented Mar 24, 2014

@leofidus Sure, if you set the setting to your locale and keep using the US decimal seperator it's possible to mess numbers up.

The confirmation dialog in 0.9 shows you the total amount formatted in all units (w/ at least two decimals), so 1.234,00 BTC, 1.234.000,00 mBTC and 1.234.000.000,00 uBTC. The extra set of decimals would be a hint...

Also: arguably a new user from the Netherlands will expect Dutch decimal/group seperators and already mess things up, as that has been our 'old way' for hundreds of years. There was already this risk...

leofidus pushed a commit to leofidus/dogecoin that referenced this pull request Mar 31, 2014
- Change bitcoinamountfield to use locale-specific number format
- Change bitcoinunits to show and parse locale-specific numbers
- If a language/territory is selected in options, this is set as default
  locale (overrides system locale).

Fixes dogecoin#3887

(cherry picked from commit
laanwj/bitcoin@db0b8f3,
bitcoin/bitcoin#3893)
leofidus pushed a commit to leofidus/dogecoin that referenced this pull request Mar 31, 2014
Tests various locales, as well as variants with and without
decimals group separators.

(cherry picked from commit
laanwj/bitcoin@9ce3106,
bitcoin/bitcoin#3893)
@laanwj
Copy link
Member Author

laanwj commented May 10, 2014

Reluctantly closing this in favour of #4167.

@laanwj laanwj closed this May 10, 2014
@laanwj laanwj mentioned this pull request Nov 26, 2014
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

qt: Format "Balance" amount using commas

5 participants