diff --git a/core/modules/views/src/Plugin/views/field/Field.php b/core/modules/views/src/Plugin/views/field/Field.php index 111a960..61d2311 100644 --- a/core/modules/views/src/Plugin/views/field/Field.php +++ b/core/modules/views/src/Plugin/views/field/Field.php @@ -723,6 +723,8 @@ public function getItems(ResultRow $values) { 'settings' => $this->options['settings'], 'label' => 'hidden', ); + // @todo (in this patch) make this able to render the langcode field itself + // for this translation. $render_array = $entity->get($this->definition['field_name'])->view($display); $items = array(); @@ -905,7 +907,12 @@ protected function addSelfTokens(&$tokens, $item) { * The field language code. */ protected function getFieldLangcode(EntityInterface $entity, ResultRow $row) { - if ($this->getFieldDefinition()->isTranslatable()) { + // Retrieve the translation language code for this field. Even though + // the language field is not translatable (it is what is used to key + // translations), apply the language code lookup for that too, because that + // allows us to display the language name itself in the right language. + $langcode_key = $entity->getEntityType()->getKey('langcode'); + if ($this->getFieldDefinition()->isTranslatable() || $this->getFieldDefinition()->getName() == $langcode_key) { // Even if the current field is not attached to the main entity, we use it // to determine the field language, as we assume the same language should // be used for all values belonging to a single row, when possible. Below