i18n API - {style: "currency"} redundant when currency is declared

# Marcos Caceres (13 years ago)

If I define a "currency" option for NumberFormat, then {style: "currency"} should automagically be set, no?

I think is redundant to have to do the following: {style: "currency", currency: "USD"}.

I should just be able to say: {currency: "USD"} without having to declare the "style".

# Nebojša Ćirić (13 years ago)

And {currency: 'USD', style:'percent'} would still produce {currency:'USD', style: 'currency'}, i.e. currency property dictates the style?

2012/9/4 Marcos Caceres <ecmascript at marcosc.com>

# Nebojša Ćirić (13 years ago)

Or we could throw TypeError in that case (style not matching).

2012/9/4 Nebojša Ćirić <cira at google.com>

# Norbert Lindenberg (13 years ago)

If we want to go this route, I'd still keep style as the primary attribute, and let currency only set the style if it isn't already set. So:

Old: {currency: "EUR"} => {style: "decimal"}

New: {currency: "EUR"} => {style: "currency", currency: "EUR"}

Unchanged:

  • {} => {style: "decimal}
  • {style: "decimal", currency: "EUR"} => {style: "decimal"}
  • {style: "percent", currency: "EUR"} => {style: "percent"}
  • {style: "currency", currency: "EUR"} => {style: "currency", currency: "EUR"}

It saves some typing, but makes the API a bit harder to explain. Comments?

Norbert