function st

Translates a string when some systems are not available.

Used during the install process, when database, theme, and localization system is possibly not yet available.

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()

get_t()

Related topics

39 calls to st()
drupal_install_config_directories in drupal/core/includes/install.inc
Creates the config directory and ensures it is operational.
drupal_rewrite_settings in drupal/core/includes/install.inc
Replaces values in settings.php with values in the submitted array.
drupal_verify_profile in drupal/core/includes/install.inc
Verifies that all dependencies are met for a given installation profile.
hook_install_tasks in drupal/core/modules/system/system.api.php
Return an array of tasks to be performed by an installation profile.
install_already_done_error in drupal/core/includes/install.core.inc
Indicates that Drupal has already been installed.

... See full list

5 string references to 'st'
get_t in drupal/core/includes/bootstrap.inc
Returns the name of the proper localization function.
LocaleInstallTest::testFunctionSignatures in drupal/core/modules/locale/lib/Drupal/locale/Tests/LocaleInstallTest.php
Verify that function signatures of t() and st() are equal.
x03.php in drupal/core/lib/Drupal/Component/Transliteration/data/x03.php
x11.php in drupal/core/lib/Drupal/Component/Transliteration/data/x11.php
xfb.php in drupal/core/lib/Drupal/Component/Transliteration/data/xfb.php

File

drupal/core/includes/install.inc, line 751
API functions for installing modules and themes.

Code

function st($string, array $args = array(), array $options = array()) {
  static $strings = NULL;
  global $install_state;
  if (empty($options['context'])) {
    $options['context'] = '';
  }
  if (!isset($strings)) {
    $strings = array();
    if (isset($install_state['parameters']['langcode'])) {

      // If the given langcode was selected, there should be at least one .po
      // file with its name in the pattern drupal-$version.$langcode.po.
      // This might or might not be the entire filename. It is also possible
      // that multiple files end with the same suffix, even if unlikely.
      $files = install_find_translation_files($install_state['parameters']['langcode']);
      if (!empty($files)) {

        // Register locale classes with the classloader. Locale module is not
        // yet enabled at this stage, so this is not happening automatically.
        drupal_classloader_register('locale', drupal_get_path('module', 'locale'));
        $strings = Gettext::filesToArray($install_state['parameters']['langcode'], $files);
      }
    }
  }
  require_once DRUPAL_ROOT . '/core/includes/theme.inc';

  // Transform arguments before inserting them
  foreach ($args as $key => $value) {
    switch ($key[0]) {

      // Escaped only
      case '@':
        $args[$key] = check_plain($value);
        break;

      // Escaped and placeholder
      case '%':
      default:
        $args[$key] = '<em>' . check_plain($value) . '</em>';
        break;

      // Pass-through
      case '!':
    }
  }
  return strtr(!empty($strings[$options['context']][$string]) ? $strings[$options['context']][$string] : $string, $args);
}