Page MenuHomePhabricator

Pass locale option to the chart renderer service
Closed, ResolvedPublic3 Estimated Story Points

Description

Apache Echarts supports internationalization and can take a locale as a option when rendering charts.

https://echarts.apache.org/handbook/en/basics/release-note/v5-feature/#internationalization

There are numerous supported locales, though it's much less than what Wikimedia uses, but I am sure more can be added:

https://github.com/apache/echarts/tree/release/src/i18n

Acceptance Criteria:

Notes:

Localization will help enable RTL languages to work better and other language-specific things.

Sign off

Event Timeline

Reedy updated the task description. (Show Details)
CCiufo-WMF edited projects, added Charts (Sprint 10); removed Charts.
CCiufo-WMF edited projects, added Charts; removed Charts (Sprint 10).
CCiufo-WMF edited projects, added Charts (Sprint 11); removed Charts.
Jdlrobson set the point value for this task to 3.Nov 18 2024, 7:41 PM

Change #1096737 had a related patch set uploaded (by Aude; author: Aude):

[mediawiki/extensions/Chart@master] Pass locale code to chart renderer service

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

CCiufo-WMF edited projects, added Charts (Sprint 13); removed Charts (Sprint 11).
CCiufo-WMF moved this task from Incoming to Code Review on the Charts (Sprint 13) board.
const locale = new Intl.Locale( language );
// Note: Only available in modern browsers, older browsers will fall back to LTR.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo
const isRTL = locale && locale.textInfo && locale.textInfo.direction === 'rtl';

Intl.Locale and getting text direction (rtl) is not available in node

Intl.NumberFormat and Intl.DateTimeFormat are available.

Jdlrobson-WMF subscribed.

Service patch is merged.
We will need to upstream a few other changes to address T381351.

To maintain backwards compatibility we'll need to fix this in the client too, so I suggest that we do all the following and make sure they are deployed before we leave for the holidays:

In January, we would then land https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Chart/ /1099833?usp=search and rely on the logic in the server for infering types.

@aude does that sound like a plan?

Left some comments in:

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Chart/ /1099827

though perhaps these could be addressed in follow-up tasks. Some charts have very small values that need more decimal place precision, like exchange rates or scientific data:

https://commons.wikimedia.beta.wmflabs.org/wiki/Data:JPYUSD_exchange_rate.chart

Screenshot 2024-12-04 at 6.54.01 PM.png (1×1 px, 106 KB)

with suggested changes:

Screenshot 2024-12-04 at 6.49.44 PM.png (1×1 px, 128 KB)

Change #1096737 merged by jenkins-bot:

[mediawiki/extensions/Chart@master] Pass locale code to chart renderer service

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

Change #1101235 had a related patch set uploaded (by Aude; author: Aude):

[mediawiki/extensions/Chart@master] Use axis formatter from chart spec

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

Change #1101235 abandoned by Aude:

[mediawiki/extensions/Chart@master] Use axis formatter from chart spec

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

Left some comments in:

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Chart/ /1099827

though perhaps these could be addressed in follow-up tasks. Some charts have very small values that need more decimal place precision, like exchange rates or scientific data:

https://commons.wikimedia.beta.wmflabs.org/wiki/Data:JPYUSD_exchange_rate.chart

Screenshot 2024-12-04 at 6.54.01 PM.png (1×1 px, 106 KB)

with suggested changes:

Screenshot 2024-12-04 at 6.49.44 PM.png (1×1 px, 128 KB)

I agree -- the current behavior is strange. Can be addressed as a follow up though!