diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index f9e0bcf..71db833 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -1462,6 +1462,11 @@ function bootstrap_hooks() { */ function t($string, array $args = array(), array $options = array()) { static $custom_strings; + $locale_exists = &drupal_static(__FUNCTION__); + + if (!isset($locale_exits)) { + $locale_exists = module_exists('locale'); + } // Merge in default. if (empty($options['langcode'])) { @@ -1483,7 +1488,7 @@ function t($string, array $args = array(), array $options = array()) { $string = $custom_strings[$options['langcode']][$options['context']][$string]; } // Translate with locale module if enabled. - elseif ($options['langcode'] != LANGUAGE_SYSTEM && ($options['langcode'] != 'en' || variable_get('locale_translate_english', FALSE)) && function_exists('locale')) { + elseif ($options['langcode'] != LANGUAGE_SYSTEM && ($options['langcode'] != 'en' || variable_get('locale_translate_english', FALSE)) && $locale_exists) { $string = locale($string, $options['context'], $options['langcode']); } if (empty($args)) { @@ -2649,8 +2654,9 @@ function language($type, $reset = FALSE) { // Reset the language manager's cache and our own. if ($reset) { - if (drupal_container()->has('language_manager')) { - drupal_container()->get('language_manager')->reset($type); + $container = drupal_container(); + if ($container->has('language_manager') && $container->isScopeActive('request')) { + $container->get('language_manager')->reset($type); } if (!isset($type)) { $languages = array();