Commit 6d64268e authored by katbailey's avatar katbailey

Only use the LanguageManager for multilingual environments

parent 1cd28eb4
...@@ -2641,7 +2641,6 @@ function get_t() { ...@@ -2641,7 +2641,6 @@ function get_t() {
function drupal_language_initialize() { function drupal_language_initialize() {
if (language_multilingual()) { if (language_multilingual()) {
$types = language_types_get_all(); $types = language_types_get_all();
include_once DRUPAL_ROOT . '/core/includes/language.inc';
foreach ($types as $type) { foreach ($types as $type) {
language_manager($type); language_manager($type);
} }
...@@ -2662,19 +2661,28 @@ function drupal_language_initialize() { ...@@ -2662,19 +2661,28 @@ function drupal_language_initialize() {
*/ */
function language_manager($type) { function language_manager($type) {
static $default_language; static $default_language;
static $initiated = FALSE; // Whether the language_manager has been initiated. // Keep track of whether the language_manager has been initiated.
static $initiated = FALSE;
// Keep track of whether we are in a multilingual environment.
static $multilingual = FALSE;
$languages = &drupal_static(__FUNCTION__, array()); $languages = &drupal_static(__FUNCTION__, array());
if ($initiated) { if ($multilingual && $initiated) {
if (!isset($languages[$type])) { if (!isset($languages[$type])) {
$languages[$type] = drupal_container()->get('language_manager')->getLanguage($type); $languages[$type] = drupal_container()->get('language_manager')->getLanguage($type);
} }
return $languages[$type]; return $languages[$type];
} }
if (drupal_container()->has('language_manager')) { if (language_multilingual()) {
$initiated = TRUE; $multilingual = TRUE;
$languages[$type] = drupal_container()->get('language_manager')->getLanguage($type); if (drupal_container()->has('language_manager')) {
return $languages[$type]; include_once DRUPAL_ROOT . '/core/includes/language.inc';
$initiated = TRUE;
$languages[$type] = drupal_container()->get('language_manager')->getLanguage($type);
return $languages[$type];
}
} }
// If this is not a multilingual environment or we have not yet entered the
// request scope, just use the default language regardless of $type.
if (isset($default_language)) { if (isset($default_language)) {
return $default_language; return $default_language;
} }
......
...@@ -275,7 +275,7 @@ function install_begin_request(&$install_state) { ...@@ -275,7 +275,7 @@ function install_begin_request(&$install_state) {
include_once DRUPAL_ROOT . '/core/includes/session.inc'; include_once DRUPAL_ROOT . '/core/includes/session.inc';
// Set up $language, so t() caller functions will still work. // Set up $language, so t() caller functions will still work.
drupal_language_initialize(); //drupal_language_initialize();
require_once DRUPAL_ROOT . '/core/includes/ajax.inc'; require_once DRUPAL_ROOT . '/core/includes/ajax.inc';
// Override the module list with a minimal set of modules. // Override the module list with a minimal set of modules.
......
...@@ -21,13 +21,7 @@ public function __construct(Request $request = NULL) { ...@@ -21,13 +21,7 @@ public function __construct(Request $request = NULL) {
} }
public function getLanguage($type) { public function getLanguage($type) {
if (language_multilingual()) { $language = language_types_initialize($type, array('request' => $this->request));
$language = language_types_initialize($type, array('request' => $this->request));
}
else {
$language = language_default();
}
return $language; return $language;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment