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

40 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'
install_select_profile_form in drupal/core/includes/install.core.inc
Form constructor for the profile selection form.
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 947
API functions for installing modules and themes.

Code

function st($string, array $args = array(), array $options = array()) {
  global $install_state;
  static $install_translation;

  // This may be invoked before the container has been initialized.
  $container = Drupal::getContainer();
  if ($container && $container
    ->has('translation')) {

    // Since the container is properly initialized, we can use standard translation.
    return t($string, $args, $options);
  }
  elseif (drupal_installation_attempted() && isset($install_state['parameters']['langcode'])) {

    // The translation service is not there yet, use a temporary one.
    if (!isset($install_translation)) {
      $install_translation = new TranslationManager();
      foreach (array(
        new CustomStrings(),
        install_file_translation_service(),
      ) as $translator) {
        $install_translation
          ->addTranslator($translator);
      }
      $install_translation
        ->setDefaultLangcode($install_state['parameters']['langcode']);
    }
    return $install_translation
      ->translate($string, $args, $options);
  }

  // Just return an untraslated string.
  return format_string($string, $args);
}