0

Currenty if I set the currency to QAR it will render as QAR in english and as ر.ق. in arabic...

console.log(new Intl.NumberFormat("en", {
    style: "currency",
    currency: "QAR",
    currencyDisplay: "symbol"
}).format(999));
// renders "QAR 999.00" 

console.log(new Intl.NumberFormat("ar", {
    style: "currency",
    currency: "QAR",
    currencyDisplay: "symbol"
}).format(999));
// renders "ر.ق.‏ 999.00"

And if I set the currency to USD it will render as $ in english and US$ in arabic

console.log(new Intl.NumberFormat("en", {
    style: "currency",
    currency: "USD",
    currencyDisplay: "symbol"
}).format(999));
//renders "$999.00"

console.log(new Intl.NumberFormat("ar", {
    style: "currency",
    currency: "USD",
    currencyDisplay: "symbol"
}).format(999));
//renders "US$ 999.00"

I personally don't speak arabic, but I've been given the translation for USD in arabic is دولار أمريكي, is there a parameter I can give to Intl.NumberFormat so if the language is 'ar' and the currency is 'USD' it renders دولار أمريكي instead of US$ (for example دولار أمريكي 999.00 instead of US$999.00), I can't find anything in the documentation.

Thanks in advance.

tldr: I want when the language is set to 'ar' to render دولار أمريكي instead of US$ or know if it's not possible with just Intl.NumberFormat

Sathania
  • 69
  • 1
  • 1
  • 7

1 Answers1

1

After tinkering more with Intl.NumberFormat I found out that currencyDisplay can be set to name, which would solve my problem.

Sathania
  • 69
  • 1
  • 1
  • 7