I want to translate all the t() strings in my theme but there's no way to filter those strings by your theme only. Instead they are bundled with Drupal interface strings which creates an excessively large export to deal with and potentially unwarranted translation requests from core strings such as:


which is located in function theme_menu_local_task of includes/menu.inc

Is there a solution on how to filter your strings by ones in your theme only?

1 Answer 1


Looks like you are looking for contexts. In t documentation:


  • $string: A string containing the English string to translate.

  • $args: An associative array of replacements to make after translation. Based on the first character of the key, the value is escaped and/or themed. See format_string() for details.

  • $options: An associative array of additional options, with the following elements:

    • 'langcode' (defaults to the current language): The language code to translate to a language other than what is used to display the page.
    • 'context' (defaults to the empty context): The context the source string belongs to.

You can have separate translations for separate contexts if you need.

  • Does that solve the ability to filter on the translate interface page?
    – AlxVallejo
    Jan 15, 2015 at 16:03
  • @AlxVallejo no, of course not directly, there are only 3 filters and context is not one of them. But it is shown in Context column, and if you will export translation to a file, your translation software might be able to filter on it. Also, some themes adds sorting to all tables, so you would be able to sort by context.
    – Mołot
    Jan 15, 2015 at 16:07
  • Ok, do you know how to refresh the build-in interface strings? I added the context but it's still not showing in the UI.
    – AlxVallejo
    Jan 15, 2015 at 16:12
  • @AlxVallejo example.com/admin/config/regional/translate/i18n_string and Refresh button? Gotta go, see you tomorrow.
    – Mołot
    Jan 15, 2015 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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