Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Currency abbreviations #81

Closed
wants to merge 7 commits into from
Closed

Conversation

davinov
Copy link
Contributor

@davinov davinov commented Nov 29, 2019

Hi,
I found the use case described in #71 quite common, and I agree that replacing the SI-prefixes is just a workaround, not a definitive solution. Therefore, I worked a bit to add a K type that will use common currency abbreviations (K for thousands, M for millions, B for billions, T for trillions). It reuses the logic of the s type, with the small difference that the count of abbreviations can vary with the locale.

The abbreviations can be customized in locale definition under the property currencyAbbreviations, so the billion B in US would become bn is GB.
Their count can also vary : in French, there is no abbreviation for trillions (T), so 1.22T will be formatted as 1220Mrds (Mrds being the french abbreviation for billions).

Closes #71

@davinov davinov changed the title Currency prefixes Currency abbreviations Nov 29, 2019
@Liggliluff
Copy link

Liggliluff commented Feb 1, 2020

Just a slight thing. CLDR disagrees on your point about French.
The French abbreviations for the magnitudes K, M, B, T are k, M, Md, Bn
"1.22T" would be formatted as "1,22 Bn" in French.

CLDR don't contain it, but theoretically it continues with: Bd, Tn, Td

@Liggliluff
Copy link

Liggliluff commented Feb 1, 2020

Second thing; the east Asian languages; Korean, Japanese and Chinese (and possibly more) uses groupings of 4. So the following:
1, 10, 100, 1K, 10K, 100K, 1M, 10M, 100M, 1B, 10B, 100B, 1T, 10T, 100T
Would in Chinese be:
1,10,100,1000,1万,10万,100万,1000万,1亿,10亿,100亿,1000亿,1兆,10兆,100兆

And like for French, the continuation that is excluded in CLDR: 京, 垓, 秭, 穰, 沟, 涧, 正, 载

Then you also got the Hindi pattern:
1, 10, 100, 1t, 10t, 1l, 10l, 1c, 10c, 1a, 10a, 1k, 10k, 1n, 10n*
* Latin characters only used as a placeholder

@davinov
Copy link
Contributor Author

davinov commented Feb 4, 2020

Just a slight thing. CLDR disagrees on your point about French.
The French abbreviations for the magnitudes K, M, B, T are k, M, Md, Bn
"1.22T" would be formatted as "1,22 Bn" in French.

CLDR don't contain it, but theoretically it continues with: Bd, Tn, Td

Thanks for pointing the CLDR, it should effectively be the reference for this implementation !
I found the Mio/Mrds ones on publications.europa.eu/code/fr/fr-5000300.htm, which seem quite an official source, yet the CLDR is much more complete and have a specification for many more languages.
I'll take some time to update the PR with the CLDR reference :)

However, I'm note sure we should implement the continuation if the CLDR doesn't indicate it. Shouldn't we stick with the standard?

@Liggliluff
Copy link

You should certainly stick to the CLDR, that is the best bet. Then everything will appear as expected, between d3-format and CLDR.

I can see the CLDR terminating at T/Bn because there's no proper abbreviation of quadrillion in English; Q could be used, but it can be mixed up with quintillion, so that's where the single letter unambiguous list ends. CLDR is primarily made by American English speaking people (that's why "en" and not "en-US" is American English, and "en-001" where "001" stands for every single country on earth with no exception, excludes countries using American English in CLDR). Otherwise we might have seen Bd, Tn, Td in French, as that's a very logical continuation. ... But that's me ranting at stupid decisions in CLDR xD

@Fil
Copy link
Member

Fil commented Jun 4, 2020

Two reservations re: the proposed French locale (on top of @Liggliluff’s).

  • a non-breaking space would be needed between the number and the suffix, but the suffix can be reattached: i.e. it should be "1 k€" rather than "1k €" (* though CLDR seems to have a weird extra space, as "1 k €").
  • kilo-euros are really upsetting with higher precision ( 1234€ becomes "1,234 k€", which I can't help but read as "1 million euros"); we might use 1 k€ or 1 234 €, but not a mix.

I'm not sure how these remarks might apply to other languages.

A few refs.:

@davinov
Copy link
Contributor Author

davinov commented Jun 8, 2020

Thanks for the feedback and references! I'll try to take this into account in my spare time soon.

@davinov davinov force-pushed the currency-prefixes branch from e03ec09 to 76c6681 Compare June 20, 2020 12:16
@davinov
Copy link
Contributor Author

davinov commented Jun 20, 2020

I took some minutes to stick to CDLR for en, fr, it, es, de, and nl locales (76c6681), and rebase the PR.
However:

  • I did not have a look to languages that have other than 3-digits grouping
  • I didn't implement the reattachment of the currency symbol for some of them

Copy link
Member

@Fil Fil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: merged with #70 into #96.

@@ -2,5 +2,6 @@
"decimal": ".",
"thousands": ",",
"grouping": [3],
"currency": ["£", ""]
"currency": ["£", ""],
"currencyAbbreviations": ["", "K", "M", "B", "T"]
Copy link

@curran curran Jul 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Language Matters: Millions, Billions and Other Large Numbers

The most commonly seen short forms for thousand, million, billion and trillion in North America and the United Kingdom, respectively, are outlined in the table below.

image

Might we consider changing locale/en-GB.json to match these?

"currencyAbbreviations": ["", "k", "m", "bn", "tn"]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed in #96

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding these. I removed them from this PR originally (7ee5a2c) because they are not indicated in the CDLR, but I think they should be!

Fil added a commit that referenced this pull request Jul 7, 2020
@curran
Copy link

curran commented Jul 8, 2020

Suggest to close this in favor of #96

@Fil
Copy link
Member

Fil commented Jul 10, 2020

closed in favor of #96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add SI-like currency format directive?
4 participants