Page MenuHomePhabricator

Create Language method for human-readable numbers
Open, Needs TriagePublic

Description

For user-friendly rendering of large numbers (such as monthly page view metrics of the site), we might want to have a way of formatting numbers in a human-readable fashion, such as "60 million" or "30 thousand" - something similar to Language::formatComputingNumbers().

Potential complications:

  • Unlike computing numbers, for real numbers sometimes the leading part of the number might need to be formatted as as well. "1 TB" sounds OK; "1 billion views" sounds awkward. That should be "one billion" or maybe "a billion".
  • Consequently, the formatted number might start with a letter, which means we should be able to differentiate between upper- and lowercase.
  • I'm sure there's some language out there which doesn't use 10^3-based grouping...

Event Timeline

Tgr created this task.Oct 28 2019, 3:49 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 28 2019, 3:49 AM
JTannerWMF moved this task from Inbox to Upcoming Work on the Growth-Team board.
JTannerWMF added a subscriber: JTannerWMF.

It was determined that it is okay if we do not get this task in for the first 1.0 deployment.

Catrope added a subscriber: Catrope.Nov 1 2019, 3:42 AM

I'm sure there's some language out there which doesn't use 10^3-based grouping...

Yes. Indic languages use 10^3 for the first group, then increments of 10^2 for all subsequent groups:

> $lang = Language::factory('hi');

> echo $lang->formatNum(123456789);
१२,३४,५६,७८९
> echo $lang->commafy(123456789);
12,34,56,789

(The first result is like 12,34,56,789 but using Hindi numerals)

Consequently, the words used to describe large numbers in India (even when speaking English) are "thousand" (=10^3), "lakh" (=10^5) and "crore" (=10^7).