简体   繁体   English

intl.NumberFormat 显示 es-ES 货币格式的错误结果

[英]intl.NumberFormat shows incorrect result for es-ES currency formatting

I expect that output for es-ES and de-DE locale to be identical.我希望 es-ES 和 de-DE 语言环境的 output 是相同的。 (I asked my Spanish colleague to check his salary slip, and he confirms that there is indeed a decimal after thousand) (我让我的西班牙同事查了他的工资单,他确认千后确实有小数)

var number = 1000;
console.log(new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(number));
console.log(new Intl.NumberFormat('es-ES', { style: 'currency', currency: 'EUR' }).format(number));

Results:结果:

> "1.000,00 €"
> "1000,00 €"

According to the Real Academia Española , the standard form in Spanish is to separate numbers in groups of three, separated with whitespace, if the number has more than four digits, ie at least five (Source: https://www.rae.es/dpd/números , section 2.a, in Spanish).根据Real Academia Española的说法,西班牙语的标准形式是将数字分成三个一组,用空格分隔,如果数字超过四位,即至少五个(来源: https://www.rae.es /dpd/números ,第 2.a 节,西班牙语)。

Actually for numbers with five digits, your code gives me the same result for de-DE and es-ES , ie a separation with a dot:实际上对于五位数的数字,您的代码为de-DEes-ES提供了相同的结果,即用点分隔:

let number2 = 10000
console.log(new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(number2));
console.log(new Intl.NumberFormat('es-ES', { style: 'currency', currency: 'EUR' }).format(number2));

gives me给我

10.000,00 €
10.000,00 €

The separation with dot seems not to be fully correct*, but that the grouping is not done for four-digit numbers seems to be in accord with the language rules of the RAE.用点分隔似乎并不完全正确*,但未对四位数字进行分组似乎符合 RAE 的语言规则。

* Actually, also in German, according to the Duden you should use spaces rather than dots, see eg https://www.duden.de/sprachwissen/rechtschreibregeln/zahlen-und-ziffern (in German). * 实际上,在德语中,根据 Duden 的说法,您应该使用空格而不是点,例如https://www.duden.de/sprachwissen/rechtschreibregeln/zahlen-und-ziffern (德语)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM