Community Documentation

get_t

5 bootstrap.inc get_t()
6 bootstrap.inc get_t()
7 bootstrap.inc get_t()
8 bootstrap.inc 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 the module administration page.

Example usage:

<?php
  $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

▾ 20 functions call get_t()

batch_process in includes/form.inc
Processes the batch.
batch_set in includes/form.inc
Opens a new batch.
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().
node_requirements in modules/node/node.module
Implements hook_requirements().
requirements1_test_requirements in modules/simpletest/tests/requirements1_test.install
Implements hook_requirements().
shortcut_install in modules/shortcut/shortcut.install
Implements hook_install().
simpletest_requirements in modules/simpletest/simpletest.install
Implements hook_requirements().
system_requirements in modules/system/system.install
Test and report Drupal installation requirements.
theme_checkbox in includes/form.inc
Returns HTML for a checkbox form element.
theme_form_element in includes/form.inc
Returns HTML for a form element.
theme_form_element_label in includes/form.inc
Returns HTML for a form element label and required marker.
theme_form_required_marker in includes/form.inc
Returns HTML for a marker for required form elements.
unicode_requirements in includes/unicode.inc
Return Unicode library status and errors.
_country_get_predefined_list in includes/iso.inc
Get an array of all country code => country name pairs.
_form_validate in includes/form.inc
Performs validation on form elements. First ensures required fields are completed, #maxlength is not exceeded, and selected options were in the list of options given to the user. Then calls user-defined validators.
_locale_batch_build in includes/locale.inc
Build a locale batch from an array of files.
_locale_import_message in includes/locale.inc
Sets an error message occurred during locale file parsing.
_unicode_check in includes/unicode.inc
Perform checks about Unicode support in PHP, and set the right settings if needed.
_update_7000_field_delete_field in modules/field/field.install
Utility function: delete a field stored in SQL storage directly from the database.

File

includes/bootstrap.inc, line 2527
Functions that need to be loaded on every Drupal request.

Code

<?php
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;
}
?>
Login or register to post comments