Page MenuHomePhabricator

Add a link edit summary is in user's language, not content's language
Closed, ResolvedPublic

Description

I dicovered that the edit summary used in the add a link feature is in the user's language, not content's language, which means that if a cswiki user has the interface in Arabic, the edit summary will be in Arabic, rather than (expected) Czech.

Should be easy to fix :).

Screencast: https://drive.google.com/file/d/1DML7fs1Fr8bM3s3Kmn8Jc3I91G-hBgTL/view?usp=sharing

Event Timeline

...it would be easy if I knew how to force content language in JS.

Or, can I suggest having it save without being in a specific language, and then displaying based on the viewer's language? This is how eg wikibase edit summaries are handled, as described in https://gerrit.wikimedia.org/g/mediawiki/extensions/Wikibase/+/223b0cbf1223e528cc27a0fd353d705915a087df/docs/topics/summaries.md

Something like the edit summary /* growthexperiments-addlink-saved:1|2|3 */ corresponding to an edit with 1 link suggestion accepted, 2 rejected, and 3 skipped. Then, for viewers in English, it would render as Link suggestions: 1 accepted, 2 rejected, 3 skipped. and for viewers in Czech Návrhy odkazů: 1 přijato, 2 odmítnuto, 3 přeskočeno. This can be done with the FormatAutocomments hook

You will have to pass the message via some non-standard mechanism, e.g. as part of HomepageHooks::getSuggestedEditsConfigJson().

kostajh triaged this task as Medium priority.May 27 2021, 11:55 AM
kostajh moved this task from Backlog to Post-release backlog on the Add-Link board.

We need to localize both growthexperiments-addlink-summary-summary and its numeric parameters in the content language. Will need to investigate the best way to specify the locale in which numbers should be localized (JS mw.language.convertNumber / PHP Language::formatNum don't allow for the locale to be explicitly set when called).

The JS language library doesn't really support using a language different from the user's current - all kinds of language settings (such as plural rules) are sent to the client via mw.config variables, and those are always in the interface language.

In PHP, you don't typically need to interact with the Language class - you'd call Message methods, Message calls Language, and Message has the inLanguage(...) and inContentLanguage() methods for selecting the language. In the rare cases where you need to use Language directly, you'd need to get a LanguageFactory from the service container, and create a Language object for the appropriate language.

Change 701184 had a related patch set uploaded (by MewOphaswongse; author: MewOphaswongse):

[mediawiki/extensions/GrowthExperiments@master] Add a link: localize edit summary in the content language

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

CS content language + EN user language

Screen Shot 2021-06-24 at 3.34.07 PM.png (108×1 px, 59 KB)

CS content language + CS user language

Screen Shot 2021-06-24 at 3.22.28 PM.png (114×1 px, 72 KB)

Since FormatAutoComments hook is called when the autocomment is rendered, we can show the edit summary in the viewer's language (instead of the editor's user language).

MMiller_WMF raised the priority of this task from Medium to High.Jul 26 2021, 5:43 PM

Change 701184 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] Add a link: localize edit summary in the viewer's language

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

Etonkovidova lowered the priority of this task from High to Medium.Aug 3 2021, 10:05 PM