From 76c6681f58a7696e6b7114fcbf3317e31e660a7f Mon Sep 17 00:00:00 2001 From: David Nowinsky Date: Sat, 20 Jun 2020 14:15:19 +0200 Subject: [PATCH] Use CLDR for currencyAbbreviations Implement en, fr, de, es, it and ln locales See https://github.com/PrestaShop/PrestaShop/blob/develop/localization/CLDR/core/common/main/.xml for reference --- locale/de-DE.json | 3 ++- locale/en-GB.json | 2 +- locale/en-US.json | 3 ++- locale/es-ES.json | 3 ++- locale/fr-FR.json | 2 +- locale/it-IT.json | 3 ++- locale/nl-NL.json | 3 ++- test/locale-test.js | 4 ++-- 8 files changed, 14 insertions(+), 9 deletions(-) diff --git a/locale/de-DE.json b/locale/de-DE.json index a249762..320d2b0 100644 --- a/locale/de-DE.json +++ b/locale/de-DE.json @@ -2,5 +2,6 @@ "decimal": ",", "thousands": ".", "grouping": [3], - "currency": ["", "\u00a0€"] + "currency": ["", "\u00a0€"], + "currencyAbbreviations": ["", "", "\u00a0Mio.", "\u00a0Mrd.", "\u00a0Bio."] } diff --git a/locale/en-GB.json b/locale/en-GB.json index dd45db2..d370be3 100644 --- a/locale/en-GB.json +++ b/locale/en-GB.json @@ -3,5 +3,5 @@ "thousands": ",", "grouping": [3], "currency": ["£", ""], - "currencyAbbreviations": ["", "k", "m", "bn", "t"] + "currencyAbbreviations": ["", "K", "M", "B", "T"] } diff --git a/locale/en-US.json b/locale/en-US.json index f075b86..d9aa81b 100644 --- a/locale/en-US.json +++ b/locale/en-US.json @@ -2,5 +2,6 @@ "decimal": ".", "thousands": ",", "grouping": [3], - "currency": ["$", ""] + "currency": ["$", ""], + "currencyAbbreviations": ["", "K", "M", "B", "T"] } diff --git a/locale/es-ES.json b/locale/es-ES.json index a249762..2ffed3a 100644 --- a/locale/es-ES.json +++ b/locale/es-ES.json @@ -2,5 +2,6 @@ "decimal": ",", "thousands": ".", "grouping": [3], - "currency": ["", "\u00a0€"] + "currency": ["", "\u00a0€"], + "currencyAbbreviations": ["", "\u00a0mil", "\u00a0M", "\u00a0mil M", "\u00a0B"] } diff --git a/locale/fr-FR.json b/locale/fr-FR.json index 349868d..151c02d 100644 --- a/locale/fr-FR.json +++ b/locale/fr-FR.json @@ -4,5 +4,5 @@ "grouping": [3], "currency": ["", "\u00a0€"], "percent": "\u202f%", - "currencyAbbreviations": ["", "K", "Mio", "Mrd"] + "currencyAbbreviations": ["", "\u00a0k", "\u00a0M", "\u00a0Md", "\u00a0Bn"] } diff --git a/locale/it-IT.json b/locale/it-IT.json index 564ed46..202322a 100644 --- a/locale/it-IT.json +++ b/locale/it-IT.json @@ -2,5 +2,6 @@ "decimal": ",", "thousands": ".", "grouping": [3], - "currency": ["€", ""] + "currency": ["€", ""], + "currencyAbbreviations": ["", "", "\u00a0Mio", "\u00a0Mrd", "\u00a0Bln"] } diff --git a/locale/nl-NL.json b/locale/nl-NL.json index 7176b37..78ab0ab 100644 --- a/locale/nl-NL.json +++ b/locale/nl-NL.json @@ -2,5 +2,6 @@ "decimal": ",", "thousands": ".", "grouping": [3], - "currency": ["€\u00a0", ""] + "currency": ["€\u00a0", ""], + "currencyAbbreviations": ["", "K", "\u00a0mln.", "\u00a0mld.", "\u00a0bln."] } diff --git a/test/locale-test.js b/test/locale-test.js index 48c21dd..dc3716c 100644 --- a/test/locale-test.js +++ b/test/locale-test.js @@ -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(); });