1

When trying to become familiar with the support of number formatting in the different browsers I found that Firefox 41 formats new Intl.NumberFormat("es-ES").format(3500) as 3 500 (with a space as the group separator) while IE 11, Edge and Google Chrome give me 3.500 (with a dot . as the group separator).

I am wondering, is that a bug in Firefox? Or is the number format allowed in Spanish in Spain ambiguous?

var d1 = 3500;
var esES = new Intl.NumberFormat("es-ES");
var formattedNumber = esES.format(d1);
document.body.insertAdjacentHTML('beforeEnd', '<p>Formatted the number ' + d1 + ' with NumberFormat ' + esES.resolvedOptions().locale + ' as ' + formattedNumber + '<\/p>');
Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
  • It's a very uncommon format here in Spain. I particularly only use it (if ever) in hand-written notes. Thousand separator is `.`. – Álvaro González Nov 01 '15 at 16:18
  • In Chrome 86, numbers < 10000 which are formatted in Spanish no longer have the thousand separator. See https://bugs.chromium.org/p/chromium/issues/detail?id=1139358 – Sebastian Kreft Nov 12 '20 at 13:28

2 Answers2

4

I have tried a Firefox nightly and it returns 3.500 instead of 3 500. Then I searched bugzilla and it looks as there have been various bug reports related to number formatting with locale "es-ES", like https://bugzilla.mozilla.org/show_bug.cgi?id=1013091 and https://bugzilla.mozilla.org/show_bug.cgi?id=1078154 which have been resolved as fixed. So it looks like the issue was regarded as a bug but it has already been fixed in the nightlies/development versions of Firefox.

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
2

Yes, I'd say it's ambiguous. Citing https://en.wikipedia.org/wiki/Decimal_mark#Digit_grouping:

Typically, [non-English-speaking] European countries employ periods or spaces: 10.000 or 10 000.

I'm not Spanish, but as a continental European I can confirm that both are equally common and well-understood1. Just don't use a comma, which is the decimal separator2. Personally I prefer a thin space.

1: Wikipedia also lists "Spain" in multiple places in their Examples section
2: This is different for Spanish as spoken in America though, see e.g. Microsofts Spanish Style Guide

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
  • And when speaking of money, the amount can also be written as `1.200,-` or `1200,-` instead of using `1200,00`. With normal numbers I do see spaces very often, but when it's about money I rarely see spaces. – Stephan Bijzitter Nov 01 '15 at 15:04
  • I'm not familiar with this spec, but does it not define the precise format? I doubt if this would be left up to the browser developer to implement based on their notion of locale standards. –  Nov 01 '15 at 16:23
  • @torazaburo: No, it is left to the implementation. It's not the responsibility of ECMA-402 to define a locale-to-formatting mapping. There a projects to standardise such, but they are supposed to change separately and be used elsewhere. As an example, ES only specifies the `Date` API, but it does not include the timezone database. – Bergi Nov 01 '15 at 17:12