Skip to content

Commit 97e9a63

Browse files
fix(i18n): by default put negative sign before currency symbol
It seems that the case where the negative sign goes between the currency symbol and the numeric value is actually the special case and that locales that require this have it built in. So we should default to having the negative sign before the symbol. See http://cldr.unicode.org/translation/number-patterns and http://unicode.org/cldr/trac/ticket/5674 Closes angular#10158
1 parent bbbe107 commit 97e9a63

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

i18n/spec/parserSpec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ describe('parsePattern', function() {
3838
parseAndExpect('#,##,##0.00\u00A4', '', '-', '\u00A4', '\u00A4', 1, 2, 2, 2, 3);
3939
parseAndExpect('#,##,##0.00\u00A4;(#,##,##0.00\u00A4)',
4040
'', '(', '\u00A4', '\u00A4)', 1, 2, 2, 2, 3);
41-
parseAndExpect('\u00A4#,##0.00', '\u00A4', '\u00A4-', '', '', 1, 2, 2, 3, 3);
41+
parseAndExpect('\u00A4#,##0.00', '\u00A4', '-\u00A4', '', '', 1, 2, 2, 3, 3);
4242
parseAndExpect('\u00A4#,##0.00;(\u00A4#,##0.00)',
4343
'\u00A4', '(\u00A4', '', ')', 1, 2, 2, 3, 3);
4444
parseAndExpect('\u00A4#,##0.00;\u00A4-#,##0.00',
4545
'\u00A4', '\u00A4-', '', '', 1, 2, 2, 3, 3);
46-
parseAndExpect('\u00A4 #,##0.00', '\u00A4 ', '\u00A4 -', '', '', 1, 2, 2, 3, 3);
46+
parseAndExpect('\u00A4 #,##0.00', '\u00A4 ', '-\u00A4 ', '', '', 1, 2, 2, 3, 3);
4747
parseAndExpect('\u00A4 #,##0.00;\u00A4-#,##0.00',
4848
'\u00A4 ', '\u00A4-', '', '', 1, 2, 2, 3, 3);
4949
parseAndExpect('\u00A4 #,##0.00;\u00A4 #,##0.00-',
5050
'\u00A4 ', '\u00A4 ', '', '-', 1, 2, 2, 3, 3);
51-
parseAndExpect('\u00A4 #,##,##0.00', '\u00A4 ', '\u00A4 -', '', '', 1, 2, 2, 2, 3);
51+
parseAndExpect('\u00A4 #,##,##0.00', '\u00A4 ', '-\u00A4 ', '', '', 1, 2, 2, 2, 3);
5252
});
5353
});

i18n/src/parser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function parsePattern(pattern) {
5656
p.negSuf = negative.substr(pos + trunkLen).replace(/\'/g, '');
5757
} else {
5858
// hardcoded '-' sign is fine as all locale use '-' as MINUS_SIGN. (\u2212 is the same as '-')
59-
p.negPre = p.posPre + '-';
59+
p.negPre = '-' + p.posPre;
6060
p.negSuf = p.posSuf;
6161
}
6262

test/ng/filter/filtersSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ describe('filters', function() {
101101

102102
it('should do basic currency filtering', function() {
103103
expect(currency(0)).toEqual('$0.00');
104-
expect(currency(-999)).toEqual('($999.00)');
104+
expect(currency(-999)).toEqual('-$999.00');
105105
expect(currency(1234.5678, "USD$")).toEqual('USD$1,234.57');
106106
expect(currency(1234.5678, "USD$", 0)).toEqual('USD$1,235');
107107
});

0 commit comments

Comments
 (0)