Page MenuHomePhabricator

Impact Module: number of pageviews in mobile impact preview should be abbreviated
Closed, ResolvedPublic

Description

The Impact module preview, featured in the mobile Newcomer homepage, serves as a gateway to invite users to discover about the details of the impact of their edits in the first place, and then as a quick access to their impact when user gathered familiarity with the tool.

To that extent, the preview card features the total number of pageviews (to articles edited by the user) in a bigger font-size.
With the current implementation of the layout, the UI looks unbalanced on smaller screens when the number of pageviews grows substantially, shrinking the first column and decreasing text legibility:

Screenshot 2019-08-12 13.27.12.png (480×640 px, 43 KB)

I propose to abbreviate numbers (according to international standards -- http://cldr.unicode.org/translation/number-patterns#TOC-Short-Numbers), for numbers bigger than 999:

Screenshot 2019-08-12 13.32.23.png (452×640 px, 39 KB)

A similar issue was discussed previously at T216217#5014975, the conversation might contain useful technical insights.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Cntlsn renamed this task from Homepage: number in mobile impact preview should be abbreviated to Homepage: number of pageviews in mobile impact preview should be abbreviated.Aug 12 2019, 11:38 AM

Moving to Q2 but @MMiller_WMF feel free to move to Q1 if this is more important to do sooner.

I belive using Intl.NumberFormat could be a good option to leverage the locale negotiation and comply to international standards. The rounding it does also seems convenient for our case. These are some examples:

Intl.NumberFormat('en', { notation: "compact", maximumFractionDigits: 1 }).format(1000);
'1K'
Intl.NumberFormat('en', { notation: "compact", maximumFractionDigits: 1 }).format(25318);
'25.3K'
Intl.NumberFormat('en', { notation: "compact", maximumFractionDigits: 1 }).format(124872);
'124.9K'
Intl.NumberFormat('en', { notation: "compact", maximumFractionDigits: 1 }).format(1248720);
'1.2M'
Intl.NumberFormat('en', { notation: "compact", maximumFractionDigits: 1 }).format(1248720000);
'1.2B'
Intl.NumberFormat('es', { notation: "compact", maximumFractionDigits: 1 }).format(2500);
'2,5 mil'
Intl.NumberFormat('hi', { notation: "compact", maximumFractionDigits: 1 }).format(2500);
'2.5 हज़ार'
Intl.NumberFormat('de', { notation: "compact", maximumFractionDigits: 1 }).format(2500);
'2500'
Intl.NumberFormat('de', { notation: "compact", maximumFractionDigits: 1 }).format(25000);
'25.000'
Intl.NumberFormat('de', { notation: "compact", maximumFractionDigits: 1 }).format(2500000);
'2,5 Mio.'
Intl.NumberFormat('pt', { notation: "compact", maximumFractionDigits: 1 }).format(2500000);
'2,5 mi'
Intl.NumberFormat('pt-BR', { notation: "compact", maximumFractionDigits: 1 }).format(2500000);
'2,5 mi'
KStoller-WMF renamed this task from Homepage: number of pageviews in mobile impact preview should be abbreviated to Impact Module: number of pageviews in mobile impact preview should be abbreviated.Jul 18 2022, 11:20 PM

I belive using Intl.NumberFormat could be a good option to leverage the locale negotiation and comply to international standards. The rounding it does also seems convenient for our case. These are some examples:

Intl.NumberFormat('en', { notation: "compact", maximumFractionDigits: 1 }).format(1000);
'1K'
Intl.NumberFormat('en', { notation: "compact", maximumFractionDigits: 1 }).format(25318);
'25.3K'
Intl.NumberFormat('en', { notation: "compact", maximumFractionDigits: 1 }).format(124872);
'124.9K'
Intl.NumberFormat('en', { notation: "compact", maximumFractionDigits: 1 }).format(1248720);
'1.2M'
Intl.NumberFormat('en', { notation: "compact", maximumFractionDigits: 1 }).format(1248720000);
'1.2B'
Intl.NumberFormat('es', { notation: "compact", maximumFractionDigits: 1 }).format(2500);
'2,5 mil'
Intl.NumberFormat('hi', { notation: "compact", maximumFractionDigits: 1 }).format(2500);
'2.5 हज़ार'
Intl.NumberFormat('de', { notation: "compact", maximumFractionDigits: 1 }).format(2500);
'2500'
Intl.NumberFormat('de', { notation: "compact", maximumFractionDigits: 1 }).format(25000);
'25.000'
Intl.NumberFormat('de', { notation: "compact", maximumFractionDigits: 1 }).format(2500000);
'2,5 Mio.'
Intl.NumberFormat('pt', { notation: "compact", maximumFractionDigits: 1 }).format(2500000);
'2,5 mi'
Intl.NumberFormat('pt-BR', { notation: "compact", maximumFractionDigits: 1 }).format(2500000);
'2,5 mi'

That sounds good to me, but let's ask around (to Language-Team especially) if there are any concerns with doing that, as I see only one minor usage in a WMF deployed extension.

@Sgs: Just saw that IE 11 doesn't support this API: Intl.NumberFormat. Will that be something to worry about incase we decide to adopt the shortening?

@Sgs: Just saw that IE 11 doesn't support this API: Intl.NumberFormat. Will that be something to worry about incase we decide to adopt the shortening?

The new impact module is gonna be built with Vue 3 which neither supports IE11 so not something to worry for adoption. I think what we need to test before giving it an ok is the locale negotiation. We should make sure it works for all the languages wiki projects support and does appropriate fallback.

We did a variant of this in SuggestedEdits::formatSiteViews() but in a somewhat shoddy way (see T236641: Create Language method for human-readable numbers). At a glance Intl does a better job, e.g. it's not bound to 10^3 powers like our code:

Intl.NumberFormat('es', { notation: "compact", maximumFractionDigits: 1 }).format(2500000);
'2,5 M'
Intl.NumberFormat('hi', { notation: "compact", maximumFractionDigits: 1 }).format(2500000);
'25 लाख'

If it were something supported in MediaWiki core, I would ask whether we are supporting more languages than browsers, as MediaWiki usually beats other software in breadth of language support, but we ended up defining our own messages in GrowthExperiments and they don't have many translations, so we are definitely better off with Intl in that regard as well.

I think what we need to test before giving it an ok is the locale negotiation. We should make sure it works for all the languages wiki projects support and does appropriate fallback.

We could set the MediaWiki language fallback chain explicitly (Intl.NumberFormat(['pt', 'pt-br', 'en'], { localeMatcher: 'lookup', ...}) - not sure how best fit matching is different exactly).

Change 860939 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[mediawiki/extensions/GrowthExperiments@master] Abbreviate pageview count in new impact module mobile summary

https://gerrit.wikimedia.org/r/860939

Change 860939 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] Abbreviate pageview count in new impact module mobile summary

https://gerrit.wikimedia.org/r/860939