diff --git a/core/modules/field/src/Plugin/views/field/Field.php b/core/modules/field/src/Plugin/views/field/Field.php index 3289db2..c114b09 100644 --- a/core/modules/field/src/Plugin/views/field/Field.php +++ b/core/modules/field/src/Plugin/views/field/Field.php @@ -309,11 +309,11 @@ public function query($use_groupby = FALSE) { // If we are grouping by something on this field, we want to group by // the displayed value, which is translated. So, we need to figure out // which language should be used to translate the value. See also - // $this->field_langcode_available(). + // $this->fieldLangcodeAvailable(). $field = $field_definition; if ($field->isTranslatable() && !empty($this->view->display_handler->options['field_langcode_add_to_query'])) { $column = $this->tableAlias . '.langcode'; - $langcode = $this->field_langcode(); + $langcode = $this->fieldLangcodeConfigured(); $placeholder = $this->placeholder(); $langcode_fallback_candidates = $this->languageManager->getFallbackCandidates(array('langcode' => $langcode, 'operation' => 'views_query', 'data' => $this)); $this->query->addWhereExpression(0, "$column IN($placeholder) OR $column IS NULL", array($placeholder => $langcode_fallback_candidates)); @@ -786,7 +786,7 @@ public function getItems(ResultRow $values) { function process_entity(EntityInterface $entity) { $processed_entity = clone $entity; - $langcode = $this->field_langcode_available($processed_entity); + $langcode = $this->fieldLangcodeAvailable($processed_entity); $processed_entity = $processed_entity->getTranslation($langcode); // If we are grouping, copy our group fields into the cloned entity. @@ -917,9 +917,9 @@ protected function addSelfTokens(&$tokens, $item) { * Return the language code of the language the field should be displayed in, * according to the settings. */ - function field_langcode_available(EntityInterface $entity) { + function fieldLangcodeAvailable(EntityInterface $entity) { if ($this->getFieldDefinition()->isTranslatable()) { - $langcode = $this->field_langcode(); + $langcode = $this->fieldLangcodeConfigured(); // Give the Entity Field API a chance to fallback to a different language // (or LanguageInterface::LANGCODE_NOT_SPECIFIED), in case the field has @@ -941,7 +941,7 @@ function field_langcode_available(EntityInterface $entity) { * @return string * Language code to be used. */ - protected function field_langcode() { + protected function fieldLangcodeConfigured() { $langcode = $this->view->display_handler->options['rendering_language']; $substitutions = static::queryLanguageSubstitutions(); $substitutions += array( diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php index 8aea75e..53ffb20 100644 --- a/core/modules/views/src/Plugin/views/PluginBase.php +++ b/core/modules/views/src/Plugin/views/PluginBase.php @@ -480,15 +480,22 @@ protected function listLanguages($flags = LanguageInterface::STATE_ALL) { // Add in negotiated languages, if requested. if ($flags & PluginBase::INCLUDE_NEGOTIATED) { $types = $manager->getDefinedLanguageTypesInfo(); + $count_named_types = 0; + $last_named_id = ''; 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. And surround // IDs by '***LANGUAGE_...***', to avoid query collisions. if (isset($type['name'])) { - $id = '***LANGUAGE_' . $id . '***'; - $list[$id] = $this->t('Page language selected by !type methods', array('!type' => $type['name'])); + $id = $last_named_id = '***LANGUAGE_' . $id . '***'; + $count_named_types++; + $list[$id] = $this->t('!type language selected for page', array('!type' => $type['name'])); } } + if ($count_named_types == 1) { + // If there was only one named type, rename the label for usability. + $list[$last_named_id] = $this->t('Language selected for page'); + } } return $list; diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index 4fb3d74..67f1471 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -215,15 +215,6 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio $this->unpackOptions($this->options, $options); } - // Convert the rendering_language and field_language_add_to_query settings. - $field_langcode = $this->getOption('rendering_language'); - $field_language_add_to_query = $this->getOption('field_language_add_to_query'); - if (isset($field_langcode)) { - $this->setOption('rendering_language', $field_langcode); - $this->setOption('field_langcode_add_to_query', $field_language_add_to_query); - $changed = TRUE; - } - // Mark the view as changed so the user has a chance to save it. if ($changed) { $this->view->changed = TRUE; diff --git a/core/modules/views_ui/src/Tests/ViewEditTest.php b/core/modules/views_ui/src/Tests/ViewEditTest.php index 5d5a476..2a60a50 100644 --- a/core/modules/views_ui/src/Tests/ViewEditTest.php +++ b/core/modules/views_ui/src/Tests/ViewEditTest.php @@ -102,7 +102,7 @@ public function testEditFormLanguageOptions() { $this->assertResponse(200); $langcode_url = 'admin/structure/views/nojs/display/' . $view_name . '/' . $display . '/rendering_language'; $this->assertNoLinkByHref($langcode_url); - $this->assertNoLink(t('Page language selected by !type methods', array('!type' => t('Content')))); + $this->assertNoLink(t('!type language selected for page', array('!type' => t('Content')))); $this->assertNoLink(t('Content language of view row')); } @@ -119,12 +119,12 @@ public function testEditFormLanguageOptions() { $langcode_url = 'admin/structure/views/nojs/display/' . $view_name . '/' . $display . '/rendering_language'; if ($view_name == 'test_view') { $this->assertNoLinkByHref($langcode_url); - $this->assertNoLink(t('Page language selected by !type methods', array('!type' => t('Content')))); + $this->assertNoLink(t('!type language selected for page', array('!type' => t('Content')))); $this->assertNoLink(t('Content language of view row')); } else { $this->assertLinkByHref($langcode_url); - $this->assertNoLink(t('Page language selected by !type methods', array('!type' => t('Content')))); + $this->assertNoLink(t('!type language selected for page', array('!type' => t('Content')))); $this->assertLink(t('Content language of view row')); }