为什么 Intl.NumberFormat 在 es-ES 语言环境中将 4 位数字一起格式化?

Why is Intl.NumberFormat formatting 4 digits together on es-ES locale?

我正在尝试使用 Intl.NumberFormat 格式化数字。

我已经检查过 MDN WebDocs 但我无法得到回复 我想应该 return.

我正在使用西班牙语语言环境进行格式化,我想获得千位之间的点分隔符(使用 useGrouping 选项),但是,我没有得到它

var sNumber = '1124.5'
var number = new Number(sNumber);

let  style = {
            style: 'currency',
            currency: "EUR",
            minimumFractionDigits: 2,
            useGrouping: true
        };

const formatter = new Intl.NumberFormat("es", style);

console.log(formatter.format(number));

这似乎是带有 4 位数字(即 1234.56)的西班牙语格式化程序的一个功能。

看看下面的运行它:

let  style = {
            style: 'currency',
            currency: "EUR",
            minimumFractionDigits: 2,
            useGrouping: true
        };
var formatter = new Intl.NumberFormat("es", style);

console.log('Spanish (ES)');
console.log(formatter.format(1234.56));
console.log(formatter.format(12345.67));
console.log(formatter.format(123456.78));

formatter = new Intl.NumberFormat("de-DE", style);

console.log('German (de-DE)');
console.log(formatter.format(1234.56));
console.log(formatter.format(12345.67));
console.log(formatter.format(123456.78));

您会看到,对于 5 位及以上的数字,西班牙语格式化程序确实按预期对数字进行了分组。

但是,如果您使用德语格式化程序 (de-DE),它会正确格式化 4 位数字。

输出:

Spanish (ES)
1234,56 €
12.345,67 €
123.456,78 €

German (de-DE)
1.234,56 €
12.345,67 €
123.456,78 €