diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index d071bc4..e8525e8 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2417,14 +2417,17 @@ function language_multilingual() { * An associative array of languages, keyed by the language code, ordered by * weight ascending and name ascending. */ -function language_list($flags = Language::STATE_CONFIGURABLE) { - - $languages = &drupal_static(__FUNCTION__); - +function language_list($flags = Language::STATE_CONFIGURABLE, $localized = FALSE) { + if (!$localized) { + $languages = &drupal_static(__FUNCTION__); + } + else { + $languages = array(); + } // Initialize master language list. - if (!isset($languages)) { + if (empty($languages)) { // Initialize local language list cache. - $languages = array(); + $languages = array(); // Fill in master language list based on current configuration. $default = language_default(); @@ -2436,10 +2439,17 @@ function language_list($flags = Language::STATE_CONFIGURABLE) { // save the same object without data loss. foreach ($language_entities as $langcode_config_name) { $langcode = substr($langcode_config_name, strlen('language.entity.')); + if ($localized) { + config_context_enter('Drupal\Core\Config\Context\LanguageConfigContext')->setLanguage(new Language(array('id' => $langcode))); + } $info = \Drupal::config($langcode_config_name)->get(); + if ($localized) { + config_context_leave(); + } $languages[$langcode] = new Language(array( 'default' => ($info['id'] == $default->id), 'name' => $info['label'], + 'label' => $info['label'], 'id' => $info['id'], 'direction' => $info['direction'], 'locked' => $info['locked'], diff --git a/core/modules/language/language.negotiation.inc b/core/modules/language/language.negotiation.inc index 79bf1e2..c06c0b0 100644 --- a/core/modules/language/language.negotiation.inc +++ b/core/modules/language/language.negotiation.inc @@ -390,17 +390,13 @@ function language_url_fallback($language = NULL, $request = NULL, $language_type * Translation links may be provided by other modules. */ function language_switcher_url($type, $path) { - $languages = language_list(); + $languages = language_list(Language::STATE_CONFIGURABLE, TRUE); $links = array(); foreach ($languages as $language) { - config_context_enter('Drupal\Core\Config\Context\LanguageConfigContext')->setLanguage($language); - $config = \Drupal::config('language.entity.' . $language->id)->get(); - $localized_language = new Language($config); - config_context_leave(); $links[$language->id] = array( 'href' => $path, - 'title' => $localized_language->label, + 'title' => $language->label, 'language' => $language, 'attributes' => array('class' => array('language-link')), );