Skip to content

Perhaps incorrect formatting when using currency pipe with locale de-AT #24609

Closed

Description

@cat-mandres

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

Current behavior

The currency pipe uses the wrong decimal symbol when called with the locale 'de-AT'.
This does not occur with the decimal pipe, it uses the correct decimal symbol.

Input: 123456789

Current output from currency pipe with locale 'de-AT': € 123 456 789.00
Expected output from currency pipe with locale 'de-AT': € 123 456 789,00

Image of the problem

Minimal reproduction of the problem with instructions

https://stackblitz.com/edit/angular-gitter-bmc7aa

What is the motivation / use case for changing the behavior?

Environment


Angular version: 6.0.5


Browser:
- [x] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Activity

  1. added
    area: i18nIssues related to localization and internationalization
    on Jun 21, 2018
  2. added this to the needsTriage milestone on Jun 21, 2018
  3. cat-mandres commented on Jun 22, 2018

    @cat-mandres
    Author

    Can this somehow be read from the locale files in the angular repo, e.g. here?

    https://github.com/angular/angular/blob/master/packages/common/locales/de-AT.ts
    https://github.com/angular/angular/blob/master/packages/common/locales/de.ts

    I cant really find the difference in here where the other symbol is defined.

  4. cat-mandres commented on Jun 22, 2018

    @cat-mandres
    Author

    Yes I know that - and if you now take the lines from the de-AT.ts file

    [',', ' ', ';', '%', '+', '-', 'E', '·', '‰', '∞', 'NaN', ':', '.'],

    and

    ['#,##0.###', '#,##0 %', '¤ #,##0.00', '#E0'], '€', 'Euro', {

    You get the following format for currencies get formatted:

    ¤ #,##0.00

    According to this method which is getting used by the currency pipe to get the number:

    export function getLocaleNumberFormat(locale: string, type: NumberFormatStyle): string {

    the dot should get replaced by the character used for decimal point.

    * | . | Replaced automatically by the character used for the decimal point. |

    now the character used for decimal point is only defined once, the first symbol in the numbers line above, which is a ,.
    Am I wrong about something here?

  5. trotyl commented on Jun 25, 2018

    @trotyl
    Contributor

    The bug is caused by the following code:

    if (symbols.currencyDecimal) {
    symbolValues.push(symbols.currencyDecimal);
    }
    if (symbols.currencyGroup) {
    symbolValues.push(symbols.currencyGroup);
    }

    There should be an else clause for currencyDecimal to push an undefined value to hold this position, like:

    if (symbols.currencyDecimal) {
      symbolValues.push(symbols.currencyDecimal);
    } else {
      symbolValues.push(undefined);
    }

    Otherwise currencyDecimal and currencyGroup would be mixed up.

    I guess a PR would be welcomed.

    Also CC: @ocombe

  6. ocombe commented on Jun 25, 2018

    @ocombe
    Contributor

    Hmm that sounds about right, good find both of you, thanks!

  7. self-assigned this
    on Jun 25, 2018
  8. modified the milestones: needsTriage, Backlog on Jun 25, 2018
  9. ocombe commented on Jun 25, 2018

    @ocombe
    Contributor

    Actually the correct format will be € 123.456.789,00 with the fix

  10. 4 remaining items

  11. cat-mandres commented on Jun 25, 2018

    @cat-mandres
    Author

    I see.
    So am I correct that the last symbol of the following line:

    [',', ' ', ';', '%', '+', '-', 'E', '·', '‰', '∞', 'NaN', ':', '.'],

    is the digit grouping symbol used for currencies if it is defined?
    And if undefined it will fallback to the 2nd symbol of this line, the digit grouping symbol for decimals.

    E.g. in the locales/de.ts file this last symbol is undefined, which means same symbol for decimals as for currencies?

  12. ocombe commented on Jun 25, 2018

    @ocombe
    Contributor

    Yes that is how the formatting rules are defined by CLDR, use the currency specific symbols if they are defined, or use the regular symbols otherwise.

  13. added a commit that references this issue on Jul 9, 2018
    a92f111
  14. added 2 commits that reference this issue on Jul 30, 2018
    5399c17
  15. angular-automatic-lock-bot commented on Sep 13, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  16. locked and limited conversation to collaborators on Sep 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions