function get_t

Returns the name of the proper localization function.

get_t() exists to support localization for code that might run during the installation phase, when some elements of the system might not have loaded.

This would include implementations of hook_install(), which could run during the Drupal installation phase, and might also be run during non-installation time, such as while installing the module from the module administration page.

Example usage:

$t = get_t();
$translated = $t('translate this');

Use t() if your code will never run during the Drupal installation phase. Use st() if your code will only run during installation and never any other time. Use get_t() if your code could run in either circumstance.

See also

t()

st()

Related topics

19 calls to get_t()
batch_process in includes/form.inc
Processes the batch.
batch_set in includes/form.inc
Adds a new batch.
form_pre_render_conditional_form_element in includes/form.inc
Adds form element theming to an element if its title or description is set.
hook_requirements in modules/system/system.api.php
Check installation requirements and do status reporting.
menu_install in modules/menu/menu.install
Implements hook_install().

... See full list

File

includes/bootstrap.inc, line 3027

Code

function get_t() {
    static $t;
    // This is not converted to drupal_static because there is no point in
    // resetting this as it can not change in the course of a request.
    if (!isset($t)) {
        $t = drupal_installation_attempted() ? 'st' : 't';
    }
    return $t;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.