Page MenuHomePhabricator

Rewrite GrowthExperiments topics i18n to make use of the ArticleTopicFiltersRegistry class
Closed, ResolvedPublic3 Estimated Story Points

Description

As part of T380825: Make ORES topics and their translations easily available to MediaWiki extensions, @Daimona / Connection-Team is creating a common architecture for ORES topics and their translations. Currently, GrowthExperiments implements its own solutions for generating eg. the topic-matching dialog:

image.png (806×505 px, 97 KB)

Originally, we added a bunch of i18n messages to GrowthExperiments for each topic, and we hardcode those i18n keys in the dialog (and other places where topic names are needed). With the step 1 changes from T380825#10536518, the i18n messages moved to WikimediaMessages, but still are the same. Soon, those keys would be renamed to no longer be GrowthExperiments-specific. Once that happens, our current solution for topic translation would break.

To prevent this from happening, we need to make use of the ArticleTopicFiltersRegistry class, which hides the exact i18n keys, and allows extensions to request the right ones on demand. Implementation would likely require adding a hard dependency on WikimediaMessages.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Urbanecm_WMF moved this task from Inbox to Backlog on the Growth-Team board.

This is fairly high priority, as it is necessary to unblock the further work on T380825: Make ORES topics and their translations easily available to MediaWiki extensions. Boldly moving to Backlog.

@Daimona Quickly checking the ArticleTopicFiltersRegistry class, and I'm wondering, how would I go around requesting a message key for a single topic? Is it reasonable to just call ArticleTopicFiltersRegistry::getTopicMessages( [ $topicName ] )? Or should we have a more efficient way of doing single-topic queries?

Implementation would likely require adding a hard dependency on WikimediaMessages.

You could also fall back to an empty list of topics when WikimediaMessages is not available. That's what we're doing in CampaignEvents. The taxonomy that the topic list is based on is also kinda Wikipedia-specific, so I do believe it would be a good idea to reflect this in the code somehow.

@Daimona Quickly checking the ArticleTopicFiltersRegistry class, and I'm wondering, how would I go around requesting a message key for a single topic? Is it reasonable to just call ArticleTopicFiltersRegistry::getTopicMessages( [ $topicName ] )? Or should we have a more efficient way of doing single-topic queries?

Yes, that is the intended way. We could add a shorthand if needed, I just thought the current implementation wasn't too inconvenient.

Yes, that is the intended way. We could add a shorthand if needed, I just thought the current implementation wasn't too inconvenient.

I was mostly thinking about effectiveness, as that method appears to build something for all topics, only to select only one. If that is fine/expected, I don't think a shorthand is necessary.

Yes, that is the intended way. We could add a shorthand if needed, I just thought the current implementation wasn't too inconvenient.

I was mostly thinking about effectiveness, as that method appears to build something for all topics, only to select only one. If that is fine/expected, I don't think a shorthand is necessary.

Ah, I see. I think it's fine, the overhead should be minimal because the topic list is of fixed size and the code is basically just doing a for loop.

KStoller-WMF lowered the priority of this task from High to Medium.Feb 17 2025, 12:04 AM
KStoller-WMF set the point value for this task to 3.Feb 18 2025, 5:54 PM

Change #1122954 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[integration/config@master] zuul: Make ContentTranslation and GrowthExperiments depend on WikimediaMessages

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

Change #1122964 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[mediawiki/extensions/GrowthExperiments@master] Obtain article topic definitions from WikimediaMessages

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

I have implemented an initial version that hard-depends on WikimediaMessages, to unblock T380825. There's more cleanup to be done that I won't be doing because I'm not sufficiently familiar with the extension.

Change #1122954 merged by jenkins-bot:

[integration/config@master] Make ContentTranslation and GrowthExperiments depend on WikimediaMessages

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

Sgs moved this task from Incoming to Code Review on the Growth-Team (Current Sprint) board.
Sgs subscribed.

We're adding into our current Sprint and we'll post code review feedback soon, thanks for working on this @Daimona

Sgs updated Other Assignee, added: Daimona.

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

[mediawiki/extensions/GrowthExperiments@master] feat(Topics): avoid hard dependency on WikimediaMessages for loading topics

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

Change #1129337 abandoned by Sergio Gimeno:

[mediawiki/extensions/GrowthExperiments@master] feat(Topics): avoid hard dependency on WikimediaMessages for loading topics

Reason:

Squashed in Ie05689c803098bda461a6de26fb17b49f41239bb

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

Change #1122964 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] Obtain article topic definitions from WikimediaMessages

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