1

I'm using currencyFormatter for my prices, and I would like to present my prices with the euro sign after the price and a full stop instead of a comma

Ej. 10.000€ (10 thousand euro).

(10000).toLocaleString(xxxx, {
  style: 'currency',
  currency: 'USD',
});

Does anyone know which unit I should use in the xxxx? Thanks for your help!

Zachary Haber
  • 8,972
  • 1
  • 11
  • 24
  • Set it to `undefined` to use browser language. Set to something like `en-US` to overwrite the locale. – 0stone0 Mar 15 '22 at 14:30

2 Answers2

0

toLocaleString should be "en-US"

Sean Lawton
  • 814
  • 5
  • 15
0

I'd suggest playing around with the locales a bit, or just leave it as undefined to use the user's locale. It appears that 'de-DE' (Germany) appears fairly close to your desired format.

As for the euro sign, you need to have currency: 'EUR' for that.

console.log((10000).toLocaleString('de-DE', {
  style: 'currency',
  currency: 'EUR',
  maximumFractionDigits: 0
}));

number#toLocaleString uses the arguments from Intl.NumberFormat which I'd suggest reading through.

In this case, I used maximumFractionDigits to remove the values after the decimal point.

Zachary Haber
  • 8,972
  • 1
  • 11
  • 24