Page MenuHomePhabricator

Clarify numerals in Arabic language for the user impact module
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Navigate to Special:Homepage using Arabic language

What happens?:

  1. The recent activity title shows a non localized numeral (see screenshot)
  2. The contributions links shows a non localized numeral (see screenshot)

What should have happened instead?:
Numbers should be localized

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Screenshot 2022-11-23 at 13.33.51.png (1×1 px, 184 KB)

Event Timeline

Change 860014 had a related patch set uploaded (by Sergio Gimeno; author: Sergio Gimeno):

[mediawiki/extensions/GrowthExperiments@master] User impact: convert numbers to locale numerals in the recent activity title and the contributions bottom link

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

Change 860014 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] User impact: convert numbers to locale numerals

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

Hi @Sgs, I think a spot was missed.

image.png (1×2 px, 577 KB)

Hi @Sgs, I think a spot was missed.

image.png (1×2 px, 577 KB)

Thank you, @EUdoh-WMF for noticing an interesting issue. I checked arwiki wmf.10 - Main page (I circled some of many numbers displayed as Arabic numerals), as well as Special:Homepage display numbers as Arabic numerals.

Screen Shot 2022-11-29 at 3.39.30 PM.png (1×2 px, 1 MB)
Screen Shot 2022-11-29 at 3.44.21 PM.png (1×2 px, 416 KB)

It seems (need to be confirmed) that Arabic numeral system is used on arwiki not Hindi numerals. @Dyolf77_WMF - do we need to do localization for numbers on arwiki?

Confirmed by @Dyolf77_WMF that Growth team projects should use Arabic numerals

I'm confused on how to use mw.language.convertNumber(). We need to call this method for the number conversion to happen in other languages like Bengali. mw.language.getDigitTransformTable() returns indeed a converstion table in ar.wikipedia.org:

Screenshot 2022-11-30 at 19.43.09.png (610×2 px, 277 KB)

We could conditionally skip the conversion for Arabic but maybe there's a configuration setting for this that we need to take in account? cc @Tgr

For context, this is how the old impact module is displayed in Arabic and Bengali

ArabicBengali
Screenshot 2022-12-01 at 10.24.47.png (908×804 px, 98 KB)
Screenshot 2022-12-01 at 10.25.04.png (848×754 px, 102 KB)
Sgs renamed this task from Wrong numerals in Arabic language to Clarify numerals in Arabic language for the user imapct module.Nov 30 2022, 6:56 PM
Aklapper renamed this task from Clarify numerals in Arabic language for the user imapct module to Clarify numerals in Arabic language for the user impact module.Nov 30 2022, 11:00 PM

Hi @Sgs, I think a spot was missed.

image.png (1×2 px, 577 KB)

Thank you, @EUdoh-WMF for noticing an interesting issue. I checked arwiki wmf.10 - Main page (I circled some of many numbers displayed as Arabic numerals), as well as Special:Homepage display numbers as Arabic numerals.

The reason for that is the copy text for Arabic language has 60 as hard coded characters as opposite of other languages like Bengali which did translate the number on the translation.
i18n/ar.json

"growthexperiments-homepage-suggestededits-pageviews": "$1 تصفّح (آخر 60 يوما)",

i18n/bn.json

"growthexperiments-homepage-suggestededits-pageviews": "$1 বার দেখা হয়েছে (গত ৬০ দিনে)"

This behaviour leaves the choice of the numeral to the translator which is probably not the best idea. The behavior in the new impact module is different because the numbers are sent to the text keys as parameters and the responsability of the translation (or not) is on the software rather than the translator:

i18n/en.json

"growthexperiments-homepage-impact-recent-activity-title": "{{GENDER:$1|Your}} recent activity (last $2 {{PLURAL:$2|day|days}})"

I think the Suggested Edits doesn't have a bug right now because the translations match the configuration of arwiki and bnwiki. However this can yield to issues in other languages. Not sure if the rule Always pass numbers as parameters to text keys or it's negate Never allow hard coded numerals in copy texts are too strict but it seems that could solve the discrepancies introduced by translators or the risk of them to exist (eg: if the wiki config policy for $wgTranslateNumerals changed).

Etonkovidova claimed this task.

I think the Suggested Edits doesn't have a bug right now because the translations match the configuration of arwiki and bnwiki. However this can yield to issues in other languages. Not sure if the rule Always pass numbers as parameters to text keys or it's negate Never allow hard coded numerals in copy texts are too strict but it seems that could solve the discrepancies introduced by translators or the risk of them to exist (eg: if the wiki config policy for $wgTranslateNumerals changed).

I think the right thing to do would be to use {{formatnum}} in the message text which applies the digit transform table if so configured (and also thousands separators if the number is large enough), as long as the message is formatted in a way that involves wikitext parsing (i.e. not via Message::plain()).

Hindi numerals appear in mobile version:

Screenshot_20221206_203311_Firefox.png (2×1 px, 413 KB)

Screenshot_20221206_203259_Firefox.png (2×1 px, 329 KB)

Screenshot_20221206_203247_Firefox.png (2×1 px, 247 KB)

In betalabs arwiki New Impact module displays correct format (confirmed by @Dyolf77_WMF):

Screen Shot 2022-12-06 at 11.53.05 AM.png (1×734 px, 139 KB)
Screen Shot 2022-12-06 at 11.48.03 AM.png (1×752 px, 156 KB)
Screen Shot 2022-12-06 at 11.42.28 AM.png (1×742 px, 127 KB)

I see Western Arabic numbers at https://ar.wikipedia.org/wiki/%D8%AE%D8%A7%D8%B5:%D8%AA%D8%A3%D8%AB%D9%8A%D8%B1/Dyolf77_(WMF)?uselang=ar
We use Intl so it probably depends on browser settings. There isn't a perfect solution given the lack of native MediaWiki support, but using the { numberingSystem: "latn" } locale parameter when $wgTranslateNumerals is false would probably be an improvement.

@Dyolf77_WMF could you test these two snippets in your browser's Javascript console (preferably on some arwiki page although it probably doesn't matter) and see if the results differ?

Intl.NumberFormat( 'ar', { notation: 'compact', maximumFractionDigits: 1 } ).format(10000)
Intl.NumberFormat( new Intl.Locale('ar', { numberingSystem: 'latn' }), { notation: 'compact', maximumFractionDigits: 1 } ).format(10000)

@Dyolf77_WMF could you test these two snippets in your browser's Javascript console (preferably on some arwiki page although it probably doesn't matter) and see if the results differ?

Same display, Hindi numerals.

With Chrome: Okay.
With Firefox: issue with the display.

image.png (563×1 px, 93 KB)

Thanks!

With Firefox: issue with the display.

Is the issue the order of the words? I think that will work out in context, the Unicode bidi algorithm relies heavily on the surroundings to determine text directionality.

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

[mediawiki/extensions/GrowthExperiments@master] Use wgTranslateNumerals with Intl

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

Change 866528 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] Use wgTranslateNumerals with Intl

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

Checked in `arwiki wmf.20.

The screenshots are from this commentarwiki wmf.20(username is removed)
Screenshot_20221206_203311_Firefox.png (2×1 px, 413 KB)
Screen Shot 2023-02-01 at 12.46.29 PM.png (1×818 px, 125 KB)
Screenshot_20221206_203259_Firefox.png (2×1 px, 329 KB)
Screen Shot 2023-02-01 at 12.46.00 PM.png (1×840 px, 127 KB)
Screenshot_20221206_203247_Firefox.png (2×1 px, 247 KB)
Screen Shot 2023-02-01 at 1.03.03 PM.png (1×850 px, 86 KB)