diff --git a/includes/output.inc b/includes/output.inc
index f036e34..4d0c0a8 100644
--- a/includes/output.inc
+++ b/includes/output.inc
@@ -135,8 +135,12 @@ function drush_format($input, $label = NULL, $format = NULL) {
  * @see t()
  */
 function dt($string, $args = array()) {
-  if (function_exists('t') && (drush_drupal_version() >= 7 || function_exists('theme'))) {
-    return t($string, $args);
+  if (function_exists('t')) {
+    $version = drush_drupal_version();
+    // We need to make sure bootstrap has a database connection.
+    if (($version < 7 && function_exists('theme')) || $version == 7 || ($version == 8 && drupal_get_bootstrap_phase() >= DRUPAL_BOOTSTRAP_CONFIGURATION )) {
+      return t($string, $args);
+    }
   }
   else {
     if (!empty($args)) {
