Skip to content

Commit

Permalink
Use CLDR for currencyAbbreviations
Browse files Browse the repository at this point in the history
  • Loading branch information
davinov committed Jun 20, 2020
1 parent a0de748 commit 76c6681
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion locale/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"decimal": ",",
"thousands": ".",
"grouping": [3],
"currency": ["", "\u00a0"]
"currency": ["", "\u00a0"],
"currencyAbbreviations": ["", "", "\u00a0Mio.", "\u00a0Mrd.", "\u00a0Bio."]
}
2 changes: 1 addition & 1 deletion locale/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"thousands": ",",
"grouping": [3],
"currency": ["£", ""],
"currencyAbbreviations": ["", "k", "m", "bn", "t"]
"currencyAbbreviations": ["", "K", "M", "B", "T"]
}
3 changes: 2 additions & 1 deletion locale/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"decimal": ".",
"thousands": ",",
"grouping": [3],
"currency": ["$", ""]
"currency": ["$", ""],
"currencyAbbreviations": ["", "K", "M", "B", "T"]
}
3 changes: 2 additions & 1 deletion locale/es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"decimal": ",",
"thousands": ".",
"grouping": [3],
"currency": ["", "\u00a0"]
"currency": ["", "\u00a0"],
"currencyAbbreviations": ["", "\u00a0mil", "\u00a0M", "\u00a0mil M", "\u00a0B"]
}
2 changes: 1 addition & 1 deletion locale/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"grouping": [3],
"currency": ["", "\u00a0"],
"percent": "\u202f%",
"currencyAbbreviations": ["", "K", "Mio", "Mrd"]
"currencyAbbreviations": ["", "\u00a0k", "\u00a0M", "\u00a0Md", "\u00a0Bn"]
}
3 changes: 2 additions & 1 deletion locale/it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"decimal": ",",
"thousands": ".",
"grouping": [3],
"currency": ["", ""]
"currency": ["", ""],
"currencyAbbreviations": ["", "", "\u00a0Mio", "\u00a0Mrd", "\u00a0Bln"]
}
3 changes: 2 additions & 1 deletion locale/nl-NL.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"decimal": ",",
"thousands": ".",
"grouping": [3],
"currency": ["\u00a0", ""]
"currency": ["\u00a0", ""],
"currencyAbbreviations": ["", "K", "\u00a0mln.", "\u00a0mld.", "\u00a0bln."]
}
4 changes: 2 additions & 2 deletions test/locale-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ tape("formatLocale({currency: [prefix, suffix]}) places the currency suffix afte
});

tape("formatLocale({currencyAbbreviations: [list of abbreviations]}) should abbreviate thousands, millions, billions and trillions", function (test) {
test.equal(d3.formatLocale({ currencyAbbreviations: ["", "k", "m", "bn", "tn"] }).format("$.3K")(1.2e9), "1.20bn");
test.equal(d3.formatLocale({ currencyAbbreviations: ["", "\u00a0k", "\u00a0M", "\u00a0Md", "\u00a0Bn"] }).format("$.3K")(1.2e9), "1.20\u00a0Md");
test.end();
});

tape("formatLocale({currencyAbbreviations: [list of abbreviations]}) should abbreviate only specified levels", function (test) {
test.equal(d3.formatLocale({ currencyAbbreviations: ["", "M", "Mio", "Mrd"] }).format("$.3K")(1.2e12), "1200Mrd");
test.equal(d3.formatLocale({ currencyAbbreviations: ["", "\u00a0k", "\u00a0M", "\u00a0Md", "\u00a0Bn"] }).format("$.3K")(1.2e15), "1200\u00a0Bn");
test.end();
});

Expand Down

0 comments on commit 76c6681

Please sign in to comment.