Wednesday, September 21, 2011

get_t() function in PHP

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 useage:
<?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.

No comments:

Post a Comment

Followers