"Andrew Garrett" agarrett@wikimedia.org wrote in message news:2916cbf61003281521r5f0f785bje90965f3d4ec88f3@mail.gmail.com...
I'm definitely a fan of trying to make our message system better and more consistent.
However, I'm not really convinced by this proposal. A few points:
- I don't like that the trivial case is Message::key() – you can't
beat the brevity of a global function, and I'd like to see something short and to the point.
- I don't like the idea of passing parameters through a call chain –
it's just not how things are really done in PHP, and it leads to all sorts of bizarre behaviour (like the bug mentioned above). It's not really in conformance with standard MediaWiki syntax. I don't see that it confers any advantages over named parameters.
I'd prefer to see a Message class (instantiated with a shorthand global function like wfMessage()) which represented an original message. Then, methods like withParameters() or withRawParameters() would create a MessageInstance class, which is like a Message class but with some parameters included. You could include the language in either the Message constructor, or you could set it with a method, perhaps setLanguage(). You could then call $msg->html(), $msg->escapedHtml(), $msg->wikitext(), $msg->escapedWikitext() or $msg->text() on EITHER the Message or MessageInstance class to get the appropriate output.
This is just off the top of my head, does anybody have any thoughts?
I'd say that, while being academically clean, isn't really how we use messages in the codebase. Messages are basically glorified strings, some of which have placeholders and some of which don't. It's pretty much unheard of to use the same message with and then without parameters, let alone to do so in the same scope, so there's not much point in having a Message factory which spits out instance subclasses, because 99% of the time you just want one message in a particular place, which may or may not need one set of parameters. It's pretty rare to even use the same message more than once within a scope.
--HM