Page MenuHomePhabricator

Add a hook to override behaviour for anon users in ULS
Open, Needs TriagePublic

Description

With a bit of evil trickery, I managed to merge the Commons uselang= language trick with the ULS so that it can be made to "work" even for anonymous users on wikimania2017wiki. (Strictly speaking, this uses the ULS as an UI for the Commons language trick).

It's very useful and user-friendly for wikis that expect a very multilingual set of anon readers (as the Wikimania wikis do), but currently the javascript for that relies on internals from ULS:

  • it relies on being able to wm.config.set the (possibly redundantly) initialize the ULS; and
  • it relies on being able to simply overwrite wm.uls.changeLanguage with another function.

This seems brittle, but useful enough that there should/could be a proper hook in ULS to implement anon user behaviour? (By (a) turning on the selector as though wgULSAnonCanChangeLanguage were true and (b) specify what happens when an anon sets language).

Code that does this: https://wikimania2017.wikimedia.org/w/index.php?title=MediaWiki:AnonymousI18N.js&oldid=692
(Look in particular at the start of the init() function)