function dt

8.0.x output.inc dt($string, $args = array())
6.x output.inc dt($string, $args = array())
7.x output.inc dt($string, $args = array())
3.x drush.inc dt($string, $args = array())
4.x drush.inc dt($string, $args = array())
5.x output.inc dt($string, $args = array())
master output.inc dt($string, $args = array())

Rudimentary replacement for Drupal API t() function.

Parameters

string: String to process, possibly with replacement item.

array: An associative array of replacement items.

Return value

The processed string.

See also

t()

Related topics

340 calls to dt()
BaseBoot::bootstrap_and_dispatch in lib/Drush/Boot/BaseBoot.php
Main entrypoint to bootstrap the selected CMS and execute the selected command.
BaseBoot::report_command_error in lib/Drush/Boot/BaseBoot.php
Called by Drush if a command is not found, or if the command was found, but did not meet requirements.
cache_drush_help in commands/core/cache.drush.inc
Implementation of hook_drush_help().
config_drush_help in commands/core/config.drush.inc
Implementation of hook_drush_help().
core_drush_help in commands/core/core.drush.inc
Implementation of hook_drush_help().

... See full list

1 string reference to 'dt'
_drush_command_translate in includes/command.inc
Helper function for drush_command_translate().

File

includes/output.inc, line 147

Code

function dt($string, $args = array()) {
  $output = NULL;
  if (function_exists('t') && drush_drupal_major_version() == 7) {
    $output = t($string, $args);
  }
  // The language system requires a working container which has the string
  // translation service.
  else if (drush_drupal_major_version() >= 8 && \Drupal::hasService('string_translation')) {
    // Drupal 8 removes !var replacements, creating a user-level error when
    // these are used, so we'll pre-replace these before calling translate().
    $legacy_args = find_legacy_dt_args($args);
    $string = strtr($string, $legacy_args);
    // Remove the legacy replacements.
    foreach (array_keys($legacy_args) as $legacy_arg_key) {
      unset($args[$legacy_arg_key]);
    }
    $output = \Drupal::translation()->translate($string, $args);
  }
  else if (function_exists('t') && drush_drupal_major_version() <= 7 && function_exists('theme')) {
    $output = t($string, $args);
  }

  // If Drupal's t() function unavailable.
  if (!isset($output)) {
    if (!empty($args)) {
      $output = strtr($string, $args);
    }
    else {
      $output = $string;
    }
  }
  return $output;
}