diff --git a/core/modules/comment/config/install/views.view.comments_recent.yml b/core/modules/comment/config/install/views.view.comments_recent.yml index 01c42df..7a4b559 100644 --- a/core/modules/comment/config/install/views.view.comments_recent.yml +++ b/core/modules/comment/config/install/views.view.comments_recent.yml @@ -228,7 +228,7 @@ display: content: 'No comments available.' tokenize: false plugin_id: text_custom - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null block_1: provider: views @@ -239,7 +239,7 @@ display: display_options: block_description: 'Recent comments' block_category: 'Lists (Views)' - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null allow: items_per_page: true diff --git a/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_field_filters.yml b/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_field_filters.yml index 9073802..aa73012 100644 --- a/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_field_filters.yml +++ b/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_field_filters.yml @@ -160,7 +160,7 @@ display: footer: { } empty: { } arguments: { } - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null page_tc: display_plugin: page @@ -169,7 +169,7 @@ display: position: 1 provider: views display_options: - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null path: test-title-filter display_description: '' @@ -180,7 +180,7 @@ display: position: 1 provider: views display_options: - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null path: test-body-paris display_description: '' @@ -241,7 +241,7 @@ display: position: 1 provider: views display_options: - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null path: test-title-paris display_description: '' @@ -301,7 +301,7 @@ display: position: 1 provider: views display_options: - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null path: test-body-filter display_description: '' diff --git a/core/modules/node/config/install/views.view.content.yml b/core/modules/node/config/install/views.view.content.yml index 6229a32..229fed6 100644 --- a/core/modules/node/config/install/views.view.content.yml +++ b/core/modules/node/config/install/views.view.content.yml @@ -536,7 +536,7 @@ display: operator: AND groups: 1: AND - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null display_plugin: default display_title: Master @@ -558,7 +558,7 @@ display: description: 'Find and manage content' menu_name: admin weight: -10 - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null display_plugin: page display_title: Page diff --git a/core/modules/node/config/install/views.view.frontpage.yml b/core/modules/node/config/install/views.view.frontpage.yml index af7cd23..2fad370 100644 --- a/core/modules/node/config/install/views.view.frontpage.yml +++ b/core/modules/node/config/install/views.view.frontpage.yml @@ -130,7 +130,7 @@ display: - views operator: in value: - language_content: 'language_content' + ***LANGUAGE_language_content***: '***LANGUAGE_language_content***' group: 1 exposed: false expose: @@ -240,7 +240,7 @@ display: relationships: { } fields: { } arguments: { } - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null display_plugin: default display_title: Master @@ -249,7 +249,7 @@ display: page_1: display_options: path: node - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null display_plugin: page display_title: Page @@ -286,5 +286,5 @@ display: view_mode: rss links: false provider: views - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null diff --git a/core/modules/node/src/Tests/Views/NodeLanguageTest.php b/core/modules/node/src/Tests/Views/NodeLanguageTest.php index 11a17b3..8300ad0 100644 --- a/core/modules/node/src/Tests/Views/NodeLanguageTest.php +++ b/core/modules/node/src/Tests/Views/NodeLanguageTest.php @@ -184,5 +184,52 @@ public function testLanguages() { } } } + + // Override the config for the front page view, so that the language + // filter is set to the site default language instead. This should just + // show the English nodes, no matter what the content language is. + $config = \Drupal::config('views.view.frontpage'); + $config->set('display.default.display_options.filters.langcode.value', array('***LANGUAGE_site_default***' => '***LANGUAGE_site_default***')); + $config->save(); + foreach ($this->node_titles as $langcode => $titles) { + $this->drupalGet(($langcode == 'en' ? '' : "$langcode/") . 'node'); + foreach ($this->node_titles as $control_langcode => $control_titles) { + foreach ($control_titles as $title) { + if ($control_langcode == 'en') { + $this->assertText($title, 'English title is shown when filtering is site default'); + } + else { + $this->assertNoText($title, 'Non-English title is not shown when filtering is site default'); + } + } + } + } + + // Override the config so that the language filter is set to the UI + // language, and make that have a fixed value of 'es'. + // + // IMPORTANT: Make sure this part of the test is last -- it is changing + // language configuration! + $config->set('display.default.display_options.filters.langcode.value', array('***LANGUAGE_language_interface***' => '***LANGUAGE_language_interface***')); + $config->save(); + $language_config = \Drupal::config('language.types'); + $language_config->set('negotiation.language_interface.enabled', array('language-selected' => 1)); + $language_config->save(); + $language_config = \Drupal::config('language.negotiation'); + $language_config->set('selected_langcode', 'es'); + $language_config->save(); + + // With a fixed language selected, there is no language-based URL. + $this->drupalGet('node'); + foreach ($this->node_titles as $control_langcode => $control_titles) { + foreach ($control_titles as $title) { + if ($control_langcode == 'es') { + $this->assertText($title, 'Spanish title is shown when filtering is fixed UI language'); + } + else { + $this->assertNoText($title, 'Non-Spanish title is not shown when filtering is fixed UI language'); + } + } + } } } diff --git a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_field_filters.yml b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_field_filters.yml index 9812a54..30626e1 100644 --- a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_field_filters.yml +++ b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_field_filters.yml @@ -173,7 +173,7 @@ display: empty: { } relationships: { } arguments: { } - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null page_tf: display_plugin: page @@ -182,7 +182,7 @@ display: position: 1 provider: views display_options: - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null path: test-title-filter display_description: '' @@ -255,7 +255,7 @@ display: position: 1 provider: views display_options: - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null path: test-body-filter display_description: '' @@ -326,7 +326,7 @@ display: position: 1 provider: views display_options: - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null path: test-body-paris display_description: '' @@ -398,7 +398,7 @@ display: position: 1 provider: views display_options: - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null path: test-title-paris display_description: '' diff --git a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_language.yml b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_language.yml index 8ecac76..c21e026 100644 --- a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_language.yml +++ b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_language.yml @@ -300,7 +300,7 @@ display: validate_options: { } plugin_id: language provider: views - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null page_1: display_plugin: page @@ -309,6 +309,6 @@ display: position: 1 provider: views display_options: - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null path: test-language diff --git a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_field_filters.yml b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_field_filters.yml index 4a84614..664f316 100644 --- a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_field_filters.yml +++ b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_field_filters.yml @@ -145,7 +145,7 @@ display: empty: { } relationships: { } arguments: { } - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null page_dc: display_plugin: page @@ -154,7 +154,7 @@ display: position: 3 provider: views display_options: - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null display_description: '' path: test-desc-filter @@ -215,7 +215,7 @@ display: position: 3 provider: views display_options: - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null display_description: '' path: test-desc-paris @@ -277,7 +277,7 @@ display: position: 1 provider: views display_options: - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null path: test-name-filter display_description: '' @@ -288,7 +288,7 @@ display: position: 1 provider: views display_options: - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null path: test-name-paris display_description: '' @@ -348,7 +348,7 @@ display: position: 3 provider: views display_options: - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null display_description: '' path: test-field-paris @@ -410,7 +410,7 @@ display: position: 3 provider: views display_options: - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null display_description: '' path: test-field-filter diff --git a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_taxonomy_tid_field.yml b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_taxonomy_tid_field.yml index 00ed470..ed3e033 100644 --- a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_taxonomy_tid_field.yml +++ b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_taxonomy_tid_field.yml @@ -172,5 +172,5 @@ display: empty: { } relationships: { } arguments: { } - field_langcode: 'language_content' + field_langcode: '***LANGUAGE_language_content***' field_langcode_add_to_query: null diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php index 399f734..b66578b 100644 --- a/core/modules/views/src/Plugin/views/PluginBase.php +++ b/core/modules/views/src/Plugin/views/PluginBase.php @@ -466,14 +466,19 @@ public function getDependencies() { * special languages have special codes that are substituted in queries by * static::queryLanguageSubstitutions(). */ - function listLanguages($flags = LanguageInterface::STATE_ALL) { + protected function listLanguages($flags = LanguageInterface::STATE_ALL) { $manager = \Drupal::languageManager(); $list = array(); // The Language Manager class takes care of the STATE_SITE_DEFAULT case. - // It comes in with ID set to 'site_default'. + // It comes in with ID set to 'site_default'. Since this is not a real + // language, surround it by '***LANGUAGE_...***', like the negotiated + // languages below. $languages = $manager->getLanguages($flags); foreach ($languages as $id => $language) { + if ($id == 'site_default') { + $id = '***LANGUAGE_' . $id . '***'; + } $list[$id] = t($language->name); } @@ -482,8 +487,10 @@ function listLanguages($flags = LanguageInterface::STATE_ALL) { $types = $manager->getDefinedLanguageTypesInfo(); foreach ($types as $id => $type) { // Omit unnamed types. These are things like language_url, which are - // not configurable and do not need to be in this list. + // not configurable and do not need to be in this list. And surround + // IDs by '***LANGUAGE_...***', to avoid query collisions. if (isset($type['name'])) { + $id = '***LANGUAGE_' . $id . '***'; $list[$id] = t('Language selected for !type', array('!type' => $type['name'])); } } @@ -510,13 +517,13 @@ public static function queryLanguageSubstitutions() { // Handle default language. $default = $manager->getDefaultLanguage()->id; - $changes['site_default'] = $default; + $changes['***LANGUAGE_site_default***'] = $default; // Handle negotiated languages. $types = $manager->getDefinedLanguageTypesInfo(); foreach ($types as $id => $type) { if (isset($type['name'])) { - $changes[$id] = $manager->getCurrentLanguage($id)->id; + $changes['***LANGUAGE_' . $id . '***'] = $manager->getCurrentLanguage($id)->id; } }