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).

Event Timeline

Change #1249056 had a related patch set uploaded (by Catrope; author: Catrope):

[design/codex-php@main] Remove i18n Mustache helper

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

Change #1249057 had a related patch set uploaded (by Catrope; author: Catrope):

[design/codex-php@main] MediaWikiLocalization: Accept MessageLocalizer instead of RequestContext

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

Change #1249058 had a related patch set uploaded (by Catrope; author: Catrope):

[design/codex-php@main] Allow a localizer to be passed into the Codex constructor

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

Catrope moved this task from Backlog to Code Review on the Codex board.

Change #1249067 had a related patch set uploaded (by Catrope; author: Catrope):

[mediawiki/core@master] OutputPage: Add getCodex() method

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

Change #1249056 merged by jenkins-bot:

[design/codex-php@main] Remove i18n Mustache helper

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

Change #1249057 merged by jenkins-bot:

[design/codex-php@main] MediaWikiLocalization: Accept MessageLocalizer instead of RequestContext

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

Change #1249058 merged by jenkins-bot:

[design/codex-php@main] Allow a localizer to be passed into the Codex constructor

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