Wikimedia

MediaWiki's parser should have a msg() helper function so people don't localize messages improperly

Using a standard wfMessage(...)->escaped() in the context of a parser function or tag hook is wrong, because it'll use the current user's language, get cached. In reviewing MediaWiki extensions, I've seen a lot of them do this wrong.

The proper invocation should be: wfMessage(...)->inLanguage( $parser->getFunctionLang() )->title( $parser->getTitle() )->escaped();

I don't think people are going to remember to properly do that every time, so we should provide a helper for them (also it took me a while to figure it out as well).

For this task you'll need to add a new msg function to the Parser class (file includes/parser/Parser.php in MediaWiki core), and then update any incorrect usages of wfMessage in the CoreTagHooks and CoreParserFunctions classes to use your new method.

Task tags

  • php
  • localization

Students who completed this task

arcaynia

Task type

  • code Code
close

2018