formatjs / dust-intl

Dust helpers for internationalization.
http://formatjs.io/dust/
Other
48 stars 11 forks source link

Currency: number representation + server/client discrepencies. #20

Open ghost opened 10 years ago

ghost commented 10 years ago
  1. Currency values seem to be uniformly returned in floating point notation. Is it possible to return a currency value in the same representation that it's passed in as? Or, at the least, allow for a notation option (notation="integer")?

    For example:
    40000, USD --> $40,000          // Integer --> Integer
    40000.00, USD --> $40,000.00    // Decimal --> Decimal
  2. In practice, I've found that currency values are returned in floating point notation on the server, but in integer notation on the client. Is there a reason for this discrepancy?

Thanks :)

caridy commented 10 years ago

Hmm, this is a very interesting issue. This is not a bug in dust-helper-intl, it might be an bug in Intl polyfill, here is a repro case trying to illustrate the issue: http://jsbin.com/fefapafe/2/edit

I tried that in chrome and firefox, and I see a consistent result, maybe I'm missing something, but I don't see the decimal output:

Native: 40000 -> $40,000
Native: 40000.00 -> $40,000
Polyfill: 40000 -> $40,000
Polyfill: 40000.00 -> $40,000

Can you double check this? How are you rendering this in dust?

ghost commented 10 years ago

Hmm, I'm increasingly thinking this is a server-side issue.

You should be able to repro if you take the /example app and slightly alter the markup like so: https://git.corp.yahoo.com/gist/gaudick/6173.

/* 40000, currency, EUR */
Raw: 40000
Value: 40.000,00 €

Screenshot here, in case it helps: http://cl.ly/image/1p3w3e3g170m