Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing space between currency code and value in currency pipe #2 #33803

Open
musterknabe opened this issue Nov 13, 2019 · 4 comments
Open

Missing space between currency code and value in currency pipe #2 #33803

musterknabe opened this issue Nov 13, 2019 · 4 comments
Assignees
Labels
area: common Issues related to APIs in the @angular/common package area: i18n P4 A relatively minor issue that is not relevant to core functions
Milestone

Comments

@musterknabe
Copy link

🐞 bug report

Affected Package

The issue is caused by package @angular/common

Is this a regression?

No

Description

The original bug was closed by a bot before it was solved (see #20708).

@ocombe wrote:

Since CLDR doesn't contain formats for finance currencies, I don't think that we can fix that. They have formats for currency accounting, but it doesn't seem to be that.
The description for the currency pattern that we use is:

Used for currency values. A currency symbol (¤) is will be replaced by the appropriate currency symbol for whatever currency is being formatted. The choice of whether to use the international currency symbols (USD, EUR, JAY, RUB,…) or localized symbols ($, €, ¥, руб.,…) is up to the application program that uses CLDR.

Which seem to point to the fact that we are indeed using the correct pattern.

You are using the correct pattern, but according to the CLDR website (http://cldr.unicode.org/translation/number-patterns) there should be a space between currency code and numbers:

¤ | 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".

@kara kara added the area: common Issues related to APIs in the @angular/common package label Nov 13, 2019
@ngbot ngbot bot added this to the needsTriage milestone Nov 13, 2019
@musterknabe
Copy link
Author

Firefox, which uses the same CLDR data internally for locale strings, formats it correctly. And so does Chrome:

(1000).toLocaleString('en-GB', {style: 'currency', currency: 'USD', currencyDisplay:'code'}) -> "USD 1,000.00"

(1000).toLocaleString('en-GB', {style: 'currency', currency: 'USD', currencyDisplay:'symbol'}) -> "US$1,000.00"

@petebacondarwin
Copy link
Member

petebacondarwin commented May 26, 2020

It does appear that we should modify our logic for applying the currency symbol. See https://unicode.org/reports/tr35/tr35-numbers.html#Currencies. I don't fully understand what is written there but it implies to me that this is a confirmed bug.

From what I read we need to be ale to apply rules generated from sections like :

        "currencyFormats-numberSystem-latn": {
          "currencySpacing": {
            "beforeCurrency": {
              "currencyMatch": "[:^S:]",
              "surroundingMatch": "[:digit:]",
              "insertBetween": " "
            },
            "afterCurrency": {
              "currencyMatch": "[:^S:]",
              "surroundingMatch": "[:digit:]",
              "insertBetween": " "
            }
          },

in numbers.json of the cldr-json file.

For reference the S in the currencyMatch refers to a "Symbol". See https://www.unicode.org/reports/tr18/#General_Category_Property and https://www.compart.com/en/unicode/category/Sc

I think we could something with preparing the data into JS regular-expressions to avoid unwanted performance loss.

@ngbot ngbot bot modified the milestones: needsTriage, Backlog Sep 17, 2020
@jelbourn jelbourn added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed severity3: broken labels Oct 1, 2020
@petebacondarwin petebacondarwin added P4 A relatively minor issue that is not relevant to core functions and removed P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent freq1: low state: confirmed triage #1 type: bug/fix labels Oct 23, 2020
@DwieDima
Copy link

There is also missing whitespace between the currency code and amount when the amount is negative:

image

When amount is positive it displays the result as expected:
image

@JeanMeche
Copy link
Member

One way to fix this would be to rely on the Intl api.

This is what is proposed in #49143

JeanMeche added a commit to JeanMeche/angular that referenced this issue Jan 13, 2024
We can delegate to Intl the formating of decimals, percents and currencies instead of relying on the Locale data.

This commit would also fix angular#33803.
JeanMeche added a commit to JeanMeche/angular that referenced this issue Jan 14, 2024
We can delegate to Intl the formating of decimals, percents and currencies instead of relying on the Locale data.

This commit would also fix angular#33803.
JeanMeche added a commit to JeanMeche/angular that referenced this issue Jan 14, 2024
We can delegate to Intl the formating of decimals, percents and currencies instead of relying on the Locale data.

This commit would also fix angular#33803.
JeanMeche added a commit to JeanMeche/angular that referenced this issue Jan 14, 2024
We can delegate to Intl the formating of decimals, percents and currencies instead of relying on the Locale data.

This commit would also fix angular#33803.
JeanMeche added a commit to JeanMeche/angular that referenced this issue Jan 21, 2024
We can delegate to Intl the formating of decimals, percents and currencies instead of relying on the Locale data.

This commit would also fix angular#33803.
JeanMeche added a commit to JeanMeche/angular that referenced this issue Jan 21, 2024
We can delegate to Intl the formating of decimals, percents and currencies instead of relying on the Locale data.

This commit would also fix angular#33803.
@JeanMeche JeanMeche self-assigned this Jan 27, 2024
JeanMeche added a commit to JeanMeche/angular that referenced this issue Apr 18, 2024
fixes angular#33803,

BREAKING CHANGE: `formatNumber`, `formatPercent`, `formatCurrencies`, `DecimalPipe`, `PercentPipe`, `CurrencyPipe` have slightly changed outputs.
JeanMeche added a commit to JeanMeche/angular that referenced this issue Apr 18, 2024
fixes angular#33803,

BREAKING CHANGE: `formatNumber`, `formatPercent`, `formatCurrencies`, `DecimalPipe`, `PercentPipe`, `CurrencyPipe` have slightly changed outputs.
JeanMeche added a commit to JeanMeche/angular that referenced this issue Apr 18, 2024
fixes angular#33803,

BREAKING CHANGE: `formatNumber`, `formatPercent`, `formatCurrencies`, `DecimalPipe`, `PercentPipe`, `CurrencyPipe` have slightly changed outputs.

ba51192

ba51192
JeanMeche added a commit to JeanMeche/angular that referenced this issue Apr 18, 2024
fixes angular#33803,

BREAKING CHANGE: `formatNumber`, `formatPercent`, `formatCurrencies`, `DecimalPipe`, `PercentPipe`, `CurrencyPipe` have slightly changed outputs.

ba51192

ba51192
JeanMeche added a commit to JeanMeche/angular that referenced this issue Apr 18, 2024
fixes angular#33803,

BREAKING CHANGE: `formatNumber`, `formatPercent`, `formatCurrencies`, `DecimalPipe`, `PercentPipe`, `CurrencyPipe` have slightly changed outputs.

ba51192

ba51192
JeanMeche added a commit to JeanMeche/angular that referenced this issue Apr 19, 2024
fixes angular#33803,

BREAKING CHANGE: `formatNumber`, `formatPercent`, `formatCurrencies`, `DecimalPipe`, `PercentPipe`, `CurrencyPipe` have slightly changed outputs.

ba51192

ba51192
JeanMeche added a commit to JeanMeche/angular that referenced this issue Apr 21, 2024
fixes angular#33803,

BREAKING CHANGE: `formatNumber`, `formatPercent`, `formatCurrencies`, `DecimalPipe`, `PercentPipe`, `CurrencyPipe` have slightly changed outputs.

ba51192

ba51192
JeanMeche added a commit to JeanMeche/angular that referenced this issue Apr 22, 2024
fixes angular#33803,

BREAKING CHANGE: `formatNumber`, `formatPercent`, `formatCurrencies`, `DecimalPipe`, `PercentPipe`, `CurrencyPipe` have slightly changed outputs.

ba51192

ba51192
JeanMeche added a commit to JeanMeche/angular that referenced this issue Apr 22, 2024
JeanMeche added a commit to JeanMeche/angular that referenced this issue Apr 22, 2024
JeanMeche added a commit to JeanMeche/angular that referenced this issue Apr 22, 2024
JeanMeche added a commit to JeanMeche/angular that referenced this issue Apr 22, 2024
JeanMeche added a commit to JeanMeche/angular that referenced this issue Apr 25, 2024
JeanMeche added a commit to JeanMeche/angular that referenced this issue Apr 25, 2024
JeanMeche added a commit to JeanMeche/angular that referenced this issue Apr 25, 2024
…nd currencies

This commit adds an `Intl` implementation to format numbers, percents and currencies.
The implementation is based on the `Intl` API and allows to drop the static imports for the locale date files.

fixes angular#33803
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: common Issues related to APIs in the @angular/common package area: i18n P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

No branches or pull requests

7 participants