admin管理员组文章数量:1389903
I expect that output for es-ES and de-DE locale to be identical. (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 €"
I expect that output for es-ES and de-DE locale to be identical. (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 €"
Share
Improve this question
edited Jan 14, 2021 at 10:07
fedorqui
291k109 gold badges590 silver badges631 bronze badges
asked Nov 22, 2019 at 9:38
maxcc00maxcc00
3454 silver badges16 bronze badges
1
- Related: Why is Intl.NumberFormat formatting 4 digits together on es-ES locale? – fedorqui Commented Jan 14, 2021 at 10:05
1 Answer
Reset to default 7According 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, i.e. at least five (Source: https://www.rae.es/dpd/números, section 2.a, in Spanish).
Actually for numbers with five digits, your code gives me the same result for de-DE
and es-ES
, i.e. a separation with a dot:
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.
* Actually, also in German, according to the Duden you should use spaces rather than dots, see e.g. https://www.duden.de/sprachwissen/rechtschreibregeln/zahlen-und-ziffern (in German).
本文标签: javascriptintlNumberFormat shows incorrect result for esES currency formattingStack Overflow
版权声明:本文标题:javascript - intl.NumberFormat shows incorrect result for es-ES currency formatting - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744572144a2613405.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论