Skip to content

Commit 2c69ac8

Browse files
Gethin Websterrxaviers
Gethin Webster
authored andcommitted
Currency: support symbol-alt-narrow (1/2)
Adds support for alternative symbols via 'symbolForm' option Ref #479 Ref #631 Ref #738
1 parent a9754b6 commit 2c69ac8

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/currency/symbol-properties.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ return function( currency, cldr, options ) {
1515
"[:digit:]": /\d/,
1616
"[:^S:]": regexpNotS
1717
},
18-
symbol = cldr.main([
18+
currencySymbols = cldr.main([
1919
"numbers/currencies",
20-
currency,
21-
"symbol"
22-
]);
20+
currency
21+
]),
22+
symbol = currencySymbols[options.symbolForm || "symbol"] || currencySymbols.symbol;
2323

2424
currencySpacing = [ "beforeCurrency", "afterCurrency" ].map(function( position ) {
2525
return cldr.main([

test/functional/currency/currency-formatter.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ define([
1919

2020
var accounting = { style: "accounting" },
2121
code = { style: "code" },
22-
name = { style: "name" },
22+
name = { style: "name" },
23+
narrow = { symbolForm: "symbol-alt-narrow" },
2324
teslaS = 69900;
2425

2526
function extraSetup() {
@@ -99,6 +100,15 @@ QUnit.test( "should return a currency formatter", function( assert ) {
99100
assert.equal( Globalize.currencyFormatter( "USD", accounting )( -1 ), "($1.00)" );
100101
});
101102

103+
QUnit.test( "should use the supplied symbolForm, falling back to standard if none is found", function( assert ) {
104+
105+
extraSetup();
106+
107+
assert.equal( Globalize.currencyFormatter( "HKD", narrow )( teslaS ), "$69,900.00" );
108+
assert.equal( Globalize.currencyFormatter( "CHF", narrow )( teslaS ), "CHF 69,900.00" );
109+
110+
});
111+
102112
// The number of decimal places and the rounding for each currency is not locale-specific data.
103113
// Those values are overriden by Supplemental Currency Data.
104114
QUnit.test( "should return a currency formatter, overriden by Supplemental Currency Data",

0 commit comments

Comments
 (0)