You are here

function t in Drupal 4

Same name and namespace in other branches
  1. 8 core/includes/bootstrap.inc \t()
  2. 5 includes/common.inc \t()
  3. 6 includes/common.inc \t()
  4. 7 includes/bootstrap.inc \t()
  5. 9 core/includes/bootstrap.inc \t()

Translate strings to the current locale.

When using t(), try to put entire sentences and strings in one t() call. This makes it easier for translators. HTML markup within translation strings is acceptable, if necessary. The suggested syntax for a link embedded within a translation string is:

$msg = t('You must log in below or <a href="%url">create a new
            account</a> before viewing the next page.', array(
  '%url' => url('user/register'),
));

We suggest the same syntax for links to other sites. This makes it easy to change link URLs if needed (which happens often) without requiring updates to translations.

Parameters

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

$args: An associative array of replacements to make after translation. Incidences of any key in this array are replaced with the corresponding value.

Return value

The translated string.

504 calls to t()
aggregator_admin_remove_feed in modules/aggregator.module
aggregator_block in modules/aggregator.module
Implementation of hook_block().
aggregator_form_category in modules/aggregator.module
Generate a form to add/edit/delete aggregator categories.
aggregator_form_category_submit in modules/aggregator.module
Process aggregator_form_category form submissions. @todo Add delete confirmation dialog.
aggregator_form_category_validate in modules/aggregator.module
Validate aggregator_form_feed form submissions.

... See full list

12 string references to 't'
archive_calendar in modules/archive.module
Generates a monthly calendar, for display in the archive block.
taxonomy_autocomplete in modules/taxonomy.module
Helper function for autocompletion
taxonomy_get_children in modules/taxonomy.module
Find all children of a term ID.
taxonomy_get_parents in modules/taxonomy.module
Find all parents of a given term ID.
taxonomy_get_term_by_name in modules/taxonomy.module
Try to map a string to an existing term, as for glossary use.

... See full list

File

includes/common.inc, line 621
Common functions that many Drupal modules will need to reference.

Code

function t($string, $args = 0) {
  global $locale;
  if (function_exists('locale') && $locale != 'en') {
    $string = locale($string);
  }
  if (!$args) {
    return $string;
  }
  else {
    return strtr($string, $args);
  }
}