With some implementation help from chx, I proposed
a new hook at issue http://drupal.org/node/127262.
I am just bringing this up here to get quick focus and a double check of idea.
The actual code change is rather small, so I was hoping it could be reviewed
and accepted/rejected early on, before the flood of more major updates and
ideas comes as we approach the code freeze.
The basic justification for this new hook
is found in the issue, pasted here for quick reference.
“As
I have been working on the functional implementation for a new community Drupal
site, I have been seeing the need to customize many of the core Drupal messages
(the drupal_set_message function), as required by the needs of the site. A
typical example would be when a contact message has been sent, the default
message is 'The message has been sent.' An small change might be to 'Thank you,
your message has been sent.' A more dynamic change would be 'Thank you Greg,
your message has been sent'.
The first
change could be accomplished using the locale module methodologies found in http://drupal.org/node/58030.
But there are two short-comings to this method. First, even though all core
modules use t() for the text to make it translation ready, many contributed
modules do not. Second, the translation method only allows for string
replacements, not dynamic insertions. Granted some of the messages place the
user's name or other dynamic information into the message, but the basic idea
is that you can only change what is given you, you can't add to it. The contact
message is a perfect example, there is no way to add the user's name to the
message.
That is
why I am going to propose a new drupal hook, hook_message_alter(&$message =
NULL), allowing the $message to be changed by reference. It would hook into the
drupal_set_message function. All messages would invoke this hook, giving
designers and developers the ability to customize those messages completely to
suit their site.”
-Greg