Drupal uses t() in various places. I was wondering if there was a way to hook into this function. Basically, if Drupal calls:

t("some string");

I wanted to modify this string and add "BOOM" at the end. I was hoping it would be as easy as this

function mymodule_t($string)
   return $string.'BOOM';

But no luck... any ideas on how to get this right?

  • Let me get this straight: You'd like to add "BOOM" to every translated string, or just to one/some of them? Feb 12, 2016 at 6:43

1 Answer 1


AFAIK Drupal's t() function does not provide any hooks for neither altering its input values nor its results.

However, if your intention is to override specific translations of the locale module, you can alter them within the translation interface of Drupal at '/admin/config/regional/translate/translate'.

If you don't want to alter the database stored locale translations, or don't have the locale module enabled, you can also provide according overrides within your settings.php by defining $conf['locale_custom_strings_' . TARGET_LANGUAGE][CONTEXT]. Replace TARGET_LANGUAGE with the target language shortcut, and CONTEXT with the context of the translation (usually an empty string):

$conf['locale_custom_strings_en'][''] = array(
  'some string' => 'some stringBOOM',

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.