Skip to content

Instantly share code, notes, and snippets.

@karelbemelmans
Created April 10, 2013 13:58
Show Gist options
  • Save karelbemelmans/5354893 to your computer and use it in GitHub Desktop.
Save karelbemelmans/5354893 to your computer and use it in GitHub Desktop.
tc()
<?php
/**
* Add context 'custom' to your translation strings.
*
* @param $string
* A string containing the English string to translate.
* @param $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.
* @param $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.
*
* @return
* The translated string.
*/
function tc($string, $args = array(), $options = array()) {
$options['context'] = 'custom';
return t($string, $args, $options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment