stellar-client icon indicating copy to clipboard operation
stellar-client copied to clipboard

Decimal and Thousands Separators

Open bartekn opened this issue 11 years ago • 2 comments

I have a friend who having more than 2,000 STR thought that she had only 2 STR. That's because in US commas are used to separate thousands. That is not valid in other locales and makes users confused. I think we can leverage navigator.language and display amounts in correct locale.

bartekn avatar Sep 29 '14 22:09 bartekn

Previous discussion: https://github.com/stellar/stellar-client/issues/614#issuecomment-51828408

There are 2 features that need to be considered:

  • Support digit grouping separators
  • Support regional decimal separators

Separately they are easy. Together they create some ambiguity. "123,456" could mean 123456 or 123.456.

Maybe something along the lines of (123456.789).toLocaleString().match(/123(.?)456(.?)789/) to detect the locale encoding?

http://stackoverflow.com/questions/4951738/culture-sensitive-parsefloat-function-in-javascript

Correlating navigator.language sounds scary (monster locale table).

Probing Number.prototype.toLocaleString() would ensure that we match the behavior of the user's browser.

deckar01 avatar Sep 29 '14 23:09 deckar01

One other thing that we could do is make the decimals be a lighter color to signify less significance

screen shot 2014-09-30 at 11 41 15 am

But then again, we already hide the non-important digits and STR shouldn't have any digits in this picture.

irisli avatar Sep 30 '14 18:09 irisli