Page MenuHomePhabricator

Codex-PHP should accept language from local context instead of global RequestContext
Open, Needs TriagePublic

Description

When Codex-PHP uses i18n messages, it uses RequestContext::getMain()->msg(), which uses the language from the global RequestContext instance (which is the user language). This isn't very clean, but it will also cause problems in certain situations, such as:

  • In parser hooks, where the target language should be used instead of the user language (via the Parser object's msg() method)
  • In ResourceLoader module callbacks, where attempting to localize messages via the global RequestContext throws an exception, because accessing user/session-specific information is not allowed (instead the ResourceLoader\Context object's msg() method should be used)

To address this, we'll need to create a way for Codex-PHP to accept a context object (technically, a MessageLocalizer), and maybe a utility method to make this easier for MW code to use (maybe we should add a getCodex() method to SpecialPage for example).