在 Drupal 7 中更改消息

2021-12-29 00:00:00 php drupal drupal-7

drupal 中有几条消息.当出现 php 警告时,会引发错误消息,但模块也可以使用 drupal_set_message() 引发消息.问题是:有没有办法改变这些消息?例如,将每条消息中的每个a"替换为b".

There is a couple of messages in drupal. When there is a php warning, an error message is raised, but a module can also raise messages with drupal_set_message(). The question is: Is there a way to alter these messages? For example to replace every 'a' with 'b' in every message.

谢谢!

推荐答案

虽然现场没有消息更改,但您可以通过 hook_preprocess_status_messages 更改显示,参见 http://api.drupal.org/api/drupal/includes--theme.inc/function/theme/7 关于预处理和 http://api.drupal.org/api/drupal/includes--theme.inc/function/theme_status_messages/7 .

While there is no message alter on set, you can change them on display via hook_preprocess_status_messages, see http://api.drupal.org/api/drupal/includes--theme.inc/function/theme/7 on preprocess and http://api.drupal.org/api/drupal/includes--theme.inc/function/theme_status_messages/7 .

您也可以尝试字符串覆盖检查 http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/t/7 ,简而言之 $conf['locale_custom_strings_en']['some message'] ='some messbge'; 为英文,如果不是英文,请将 _en 更改为其他内容.

also you can try string overrides check http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/t/7 , in short $conf['locale_custom_strings_en']['some message'] = 'some messbge'; for English, change _en for something else if it's not English.

相关文章