Intl.NumberFormat 不正确

Intl.NumberFormat not doing millions correct

所以我有一个 table 大货币值,我正在使用国际数字格式化程序,如下所示:

const formatCurrency = new Intl.NumberFormat("en-IN", {
    style: "currency",
    currency: "USD",
    minimumFractionDigits: 0,
    currencyDisplay: "narrowSymbol"
})

但是当数字大于 5 位时,输出将“,”放在错误的位置。像这样:2,75,450 美元。应该是 275,450 美元。或者像这样:14,75,099 美元。应该是 1,475,099 美元。

我查看了文档但没有找到任何东西,但我很可能遗漏了一些东西。

帮忙?

您将印度英语指定为语言环境 (en-IN)。

,75,099 印度的正确格式,代表140万7.5万和99,因为他们使用不同的单位(,475,099是错误的,因为百万不是那里常用的单位。

您可以在 Wikipedia 上阅读有关印度编号系统的更多信息:

The Indian numbering system is used in the Indian subcontinent to express large numbers. The terms lakh (100,000) and crore (10,000,000) are the most commonly used terms (even in English, such as in a local variety called Indian English) to express large numbers in the system. For example, 150,000 rupees in India is referred to as "1.5 lakh rupees", which is written as 1,50,000 rupees; 30,000,000 (thirty million) rupees is referred to as "3 crore rupees", which is written as 3,00,00,000 rupees with commas at the thousand, lakh, and crore places.

[...]

The Indian numbering system uses separators differently from the international norm. Instead of grouping digits by threes as in the international system, the Indian numbering system groups the rightmost three digits together (until the hundreds place), and thereafter groups by sets of two digits. One trillion would thus be written as 10,00,00,00,00,000 or 10 kharab (or one lakh crore). This makes the number convenient to read using the system's terminology.

(强调我的。)

如果这是一个错误并且您不想要印度语言环境,那么您需要更改代码以使用例如en-USen-UK 而不是 en-IN.