I'm just beginning to learn PHP syntax and I keep running into source that I've never seen, and can't seem to find reference to the material in the PHP documentation.

I keep seeing this type of code in PHP snippet examples:

<?php
$form['preview'] = array(
  '#type' => 'button',
  '#value' => t('Preview'),
);
?> 

What exactly is the t() function?? I have found no reference to it anywhere.

Comments

adobo’s picture

Hi, take a look at Drupal API page on 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:

nevets’s picture

t() function is part of Drupal, you can read more about it here. In general you can look up core drupal functions on the drupal api home page

zoon_unit’s picture

That makes sense now. I didn't think to look at the API. Getting up to speed in PHP and how it's used in Drupal is pretty daunting, but at least now I know where to look when I run up on something unrecognizable.

ckeo’s picture

t() and l() are in common.inc.

Craig.