Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.809
diff -u -p -r1.809 common.inc
--- includes/common.inc	15 Oct 2008 16:05:51 -0000	1.809
+++ includes/common.inc	11 Oct 2008 06:01:33 -0000
@@ -875,24 +875,27 @@ function t($string, $args = array(), $la
   global $language;
   static $custom_strings;
 
-  if (!isset($langcode)) {
-    $langcode = $language->language;
-  }
-
-  // First, check for an array of customized strings. If present, use the array
-  // *instead of* database lookups. This is a high performance way to provide a
-  // handful of string replacements. See settings.php for examples.
-  // Cache the $custom_strings variable to improve performance.
-  if (!isset($custom_strings[$langcode])) {
-    $custom_strings[$langcode] = variable_get('locale_custom_strings_' . $langcode, array());
-  }
-  // Custom strings work for English too, even if locale module is disabled.
-  if (isset($custom_strings[$langcode][$string])) {
-    $string = $custom_strings[$langcode][$string];
-  }
-  // Translate with locale module if enabled.
-  elseif (function_exists('locale') && $langcode != 'en') {
-    $string = locale($string, $langcode);
+  // We only try to translate if the language system is bootstrapped.
+  if (drupal_get_bootstrap_phase() >= DRUPAL_BOOTSTRAP_LANGUAGE) {
+    if (!isset($langcode)) {
+      $langcode = isset($language->language) ? $language->language : 'en';
+    }
+
+    // First, check for an array of customized strings. If present, use the array
+    // *instead of* database lookups. This is a high performance way to provide a
+    // handful of string replacements. See settings.php for examples.
+    // Cache the $custom_strings variable to improve performance.
+    if (!isset($custom_strings[$langcode])) {
+      $custom_strings[$langcode] = variable_get('locale_custom_strings_' . $langcode, array());
+    }
+    // Custom strings work for English too, even if locale module is disabled.
+    if (isset($custom_strings[$langcode][$string])) {
+      $string = $custom_strings[$langcode][$string];
+    }
+    // Translate with locale module if enabled.
+    elseif (function_exists('locale') && $langcode != 'en') {
+      $string = locale($string, $langcode);
+    }
   }
   if (empty($args)) {
     return $string;
