Skip to content

Commit 4ec5e28

Browse files
ocombejasonaden
authored andcommitted
fix(common): use correct group separator for currency pipe (#18932)
PR Close #18932
1 parent 4fa6ae8 commit 4ec5e28

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

packages/common/src/i18n/locale_data_api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ export function getLocaleNumberSymbol(locale: string, symbol: NumberSymbol): str
325325
if (symbol === NumberSymbol.CurrencyDecimal) {
326326
return data[LocaleDataIndex.NumberSymbols][NumberSymbol.Decimal];
327327
} else if (symbol === NumberSymbol.CurrencyGroup) {
328-
return data[LocaleDataIndex.NumberSymbols][NumberSymbol.Decimal];
328+
return data[LocaleDataIndex.NumberSymbols][NumberSymbol.Group];
329329
}
330330
}
331331
return res;

packages/common/test/pipes/number_pipe_spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import localeEn from '../../locales/en';
1010
import localeEsUS from '../../locales/es-US';
11+
import localeFr from '../../locales/fr';
1112
import {registerLocaleData, CurrencyPipe, DecimalPipe, PercentPipe} from '@angular/common';
1213
import {beforeEach, describe, expect, it} from '@angular/core/testing/src/testing_internal';
1314

@@ -16,6 +17,7 @@ export function main() {
1617
beforeAll(() => {
1718
registerLocaleData(localeEn);
1819
registerLocaleData(localeEsUS);
20+
registerLocaleData(localeFr);
1921
});
2022

2123
function isNumeric(value: any): boolean { return !isNaN(value - parseFloat(value)); }
@@ -72,6 +74,8 @@ export function main() {
7274
it('should return correct value for numbers', () => {
7375
expect(pipe.transform(1.23)).toEqual('123%');
7476
expect(pipe.transform(1.2, '.2')).toEqual('120.00%');
77+
expect(pipe.transform(1.2, '4.2')).toEqual('0,120.00%');
78+
expect(pipe.transform(1.2, '4.2', 'fr')).toEqual('0 120,00 %');
7579
});
7680

7781
it('should not support other objects',
@@ -93,6 +97,9 @@ export function main() {
9397
expect(pipe.transform(5.1234, 'USD', 'symbol')).toEqual('$5.12');
9498
expect(pipe.transform(5.1234, 'CAD', 'symbol')).toEqual('CA$5.12');
9599
expect(pipe.transform(5.1234, 'CAD', 'symbol-narrow')).toEqual('$5.12');
100+
expect(pipe.transform(5.1234, 'CAD', 'symbol-narrow', '5.2-2')).toEqual('$00,005.12');
101+
expect(pipe.transform(5.1234, 'CAD', 'symbol-narrow', '5.2-2', 'fr'))
102+
.toEqual('00 005,12 $');
96103
});
97104

98105
it('should not support other objects',

0 commit comments

Comments
 (0)