Mugetsu
Mugetsu

Reputation: 1958

Intl NuberFormat bad thai currency

I'm trying to get some currencyFormatter for the application but I encountered some problem.

I am able to use most of the currency formats with corresponding symbols correctly i.e.

var usd = new Intl.NumberFormat('en-GB', { style: 'currency', currency: 'GBP' }).format(12345);
var euro = new Intl.NumberFormat('pt-br', { style: 'currency', currency: 'EUR' }).format(12345);
var deEuro = new Intl.NumberFormat('de', { style: 'currency', currency: 'EUR' }).format(12345);

£12,345.00
€12.345,00
12.345,00 €

But when I want to format to Thailand Baht it's not displaying ฿ symbol. Instead, it's THB... Am I doing something wrong or it's not mapped?

var thai = new Intl.NumberFormat('th', { style: 'currency', currency: 'THB' }).format(12345);


THB 12,345.00

I can replace the string after but it's not convenient for me doing this...

var thai = new Intl.NumberFormat('th', { style: 'currency', currency: 'THB' }).format(12345).replace(/\b(\w*THB\w*)\b/, '฿ ');

฿ 12,345.00

Upvotes: 0

Views: 2784

Answers (1)

paranaaan
paranaaan

Reputation: 1735

try this

new Intl.NumberFormat('th-TH', { style: 'currency', currency: 'THB' }).format(12345)

Output : "฿12,345.00"

Upvotes: 1

Related Questions