Why does the JS Internationalization API for number formatting contradict German standards?

倾然丶 夕夏残阳落幕 提交于 2021-01-28 01:58:00

问题


Today I became aware of the ECMAScript Internationalisation API, as I was researching a sane way to format numbers. Thus I tested for German by calling

Intl.NumberFormat("de").format(10000.23)

on the console in Firefox and Chrome, which provides me with "10.000,23".

However this form of number formatting is discouraged in German according to the DIN 5008 standard (and the official language reference "Duden"), which says that thin spaces (\u2009) should be used as a thousand separator.

Who defined the use of this thousand separator for German localisation? The Unicode Consortium or the browser vendors?

(Yes, I am aware that some programs and persons may use the dot as German localisation approach)


回答1:


The definition is stemming from the CLDR (Unicode Common Locale Data Repository)

I filed a bug report about this issue there.




回答2:


It's in parts a matter of "better safe than sorry". DIN 5008 section 6.4: "The separator for amounts of money should be the period" (my paraphrasing) and how does a program know that?. Typography with spaces is also a problem in HTML and in most programming languages. You can easily replace periods with spaces but it's more complicated the other way around.

So, it's not a bug, it was done intentionally.



来源:https://stackoverflow.com/questions/33961284/why-does-the-js-internationalization-api-for-number-formatting-contradict-german

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!