Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Improper spacing with Intl.NumberFormat(..., {style: currency, ...})? #221

@belden

Description

@belden

Why does the following code not put a space after PYG?

new Intl.NumberFormat('es-MX', {style: 'currency', currency: 'PYG'}).format(12345);
// "PYG12,345"

This missing space occurs with:

  • Chrome 52 built-in Intl
  • Firefox 45 built-in Intl
  • this project's Intl.js

The CLDR definition for ¤ says:

This will be replaced by a currency symbol, such as $ or USD. Note: by default a space is automatically added between letters in a currency symbol and adjacent numbers. So you don't need to add a space between them if your language writes "$12" but "USD 12".

(emphasis mine)

The relevant section from the CLDR data files for es-MX seems to come from es_419.xml:

<currencyFormats numberSystem="latn">
        <currencyFormatLength>
                <currencyFormat type="standard">
                        <pattern>¤#,##0.00</pattern>
                </currencyFormat>
                <currencyFormat type="accounting">
                        <pattern>¤#,##0.00</pattern>
                </currencyFormat>
        </currencyFormatLength>
</currencyFormats>

It appears from the quoted document above that the intent of the line <pattern>¤#,##0.00</pattern> is that the above JavaScript should show PYG 12,345.

Why does the output of this library, and the native Intl libraries, not include the space after PYG?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions