In this section I would like to explain on the smallest and pretty use-full 2 functions in Drupal (using Drupal 7 as reference), l() and t().
t() : This is the function is used to translates a string to the current language or to a given language
Syntax : t($string, array $args = array(), array $options = array())
string $string : A string containing the English string to translate.
array $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.
array $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.
t(“If you don’t want to receive such e-mails, you can change your settings at !url.”, array(‘!url’ => l(t(‘My account’), “user/$account->uid”)));
l() : This is used to format links as HTML tags.
Syntax : l($text, $path, array $options = array());
string $text : The translated link text for the anchor tag.
string $path : The internal path or external URL being linked to, such as “node/34” or “http://example.com/foo”. After the url() function is called to construct the URL from $path and $options, the resulting URL is passed through check_plain() before it is inserted into the HTML anchor tag, to ensure well-formed HTML. See url() for more information and notes.
array $options : An associative array of additional options. Defaults to an empty array. It may contain the following elements.
– ‘attributes’ : An associative array of HTML attributes to apply to the anchor tag. If element ‘class’ is included, it must be an array; ‘title’ must be a string; other elements are more flexible, as they just need to work in a call to drupal_attributes($options[‘attributes’]).
– ‘html’ (default FALSE) : Whether $text is HTML or just plain-text. For example, to make an image tag into a link, this must be set to TRUE, or you will see the escaped HTML image tag. $text is not sanitized if ‘html’ is TRUE. The calling function must ensure that $text is already safe.
– ‘language’ : An optional language object. If the path being linked to is internal to the site, $options[‘language’] is used to determine whether the link is “active”, or pointing to the current page (the language as well as the path must match).
Example : l(‘About’,’about-us’,array(‘attributes’ => array(‘class’ => array(‘about_link’))));