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

Commit 96f2e3b

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 #10158
1 parent 70ce425 commit 96f2e3b

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
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

src/ng/filter/filters.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
}
4646
element(by.model('amount')).clear();
4747
element(by.model('amount')).sendKeys('-1234');
48-
expect(element(by.id('currency-default')).getText()).toBe('($1,234.00)');
49-
expect(element(by.id('currency-custom')).getText()).toBe('(USD$1,234.00)');
50-
expect(element(by.id('currency-no-fractions')).getText()).toBe('(USD$1,234)');
48+
expect(element(by.id('currency-default')).getText()).toBe('-$1,234.00');
49+
expect(element(by.id('currency-custom')).getText()).toBe('-USD$1,234.00');
50+
expect(element(by.id('currency-no-fractions')).getText()).toBe('-USD$1,234');
5151
});
5252
</file>
5353
</example>

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)