4

I have noticed that the formating of several countries (Poland, Russia, France and more) follows a strange behaviour. The format starts to apply on values with more that 4 digits. You can see it in the code below.

Unfortunately I haven't found any international standards for that and I have seen that in other programing languages the format for this countries starts from the 4th digit.

I am wondering if the Intl.NumberFormat follows the correct formatting standards.

const simpleFormat = new Intl.NumberFormat('pl-PL', {
  style: 'decimal'});
let short = simpleFormat.format(1234);
let long = simpleFormat.format(12345);

console.log(short);
console.log(long);

Expected output:

1 234

12 345

Marek Skiba
  • 2,124
  • 1
  • 28
  • 31
  • According to [ECMA 402](https://tc39.es/ecma402/#annex-implementation-dependent-behaviour), "Localized decimal and grouping separators" are implementation-dependent. I'm seeing what you're seeing on Firefox 85.0, Arch Linux: `1234` and `12 345`. – Thomas Feb 08 '21 at 14:22
  • 2
    As a datapoint, Estonian uses similar logic where you don't insert a space for 4-digit numbers (`1234`), but you do for 5-digit ones (`12 345`). While I haven't traced down the official spec here, I wouldn't find it surprising if Polish did something similar. – Etheryte Feb 08 '21 at 16:33

1 Answers1

0

in case anyone is still looking for it - Intl.NumberFormat has an option useGrouping and if it is set to true for pl then space separator is also inserted in the 4-digit number