diff --git a/core/modules/node/config/schema/node.views.schema.yml b/core/modules/node/config/schema/node.views.schema.yml index f3521e3..7f3e4d5 100644 --- a/core/modules/node/config/schema/node.views.schema.yml +++ b/core/modules/node/config/schema/node.views.schema.yml @@ -94,12 +94,12 @@ views.argument_validator.node: label: 'Filter value format' views.field.node_language: - type: views_field + type: views.field.node label: 'Node language' mapping: - link_to_node: + native_language: type: boolean - label: 'Link this field to the original piece of content' + label: 'Display in native language' views.field.node: type: views_field diff --git a/core/modules/node/src/Plugin/views/field/Language.php b/core/modules/node/src/Plugin/views/field/Language.php index 5614545..8146615 100644 --- a/core/modules/node/src/Plugin/views/field/Language.php +++ b/core/modules/node/src/Plugin/views/field/Language.php @@ -30,10 +30,9 @@ protected function defineOptions() { public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['native_language'] = array( - '#title' => $this->t('Native language'), + '#title' => $this->t('Display in native language'), '#type' => 'checkbox', '#default_value' => $this->options['native_language'], - '#description' => $this->t('If enabled, the native name of the language will be displayed'), ); } diff --git a/core/modules/views/config/schema/views.field.schema.yml b/core/modules/views/config/schema/views.field.schema.yml index c515361..8a28f38 100644 --- a/core/modules/views/config/schema/views.field.schema.yml +++ b/core/modules/views/config/schema/views.field.schema.yml @@ -178,3 +178,7 @@ views.field.xss: views.field.language: type: views_field label: 'Language' + mapping: + native_language: + type: boolean + label: 'Display in native language' diff --git a/core/modules/views/src/Plugin/views/field/LanguageField.php b/core/modules/views/src/Plugin/views/field/LanguageField.php index 5792bd0..11a5749 100644 --- a/core/modules/views/src/Plugin/views/field/LanguageField.php +++ b/core/modules/views/src/Plugin/views/field/LanguageField.php @@ -29,10 +29,9 @@ protected function defineOptions() { public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['native_language'] = array( - '#title' => $this->t('Native language'), + '#title' => $this->t('Display in native language'), '#type' => 'checkbox', '#default_value' => $this->options['native_language'], - '#description' => $this->t('If enabled, the native name of the language will be displayed'), ); } @@ -40,11 +39,9 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { * {@inheritdoc} */ public function render(ResultRow $values) { - // @todo: Drupal Core dropped native language until config translation is - // ready, see http://drupal.org/node/1616594. $value = $this->getValue($values); - $language = language_load($value); - return $language ? $language->getName() : ''; - } + $languages = $this->options['native_language'] ? \Drupal::languageManager()->getNativeLanguages() : \Drupal::languageManager()->getLanguages(); + return isset($languages[$value]) ? $languages[$value]->getName() : ''; + } }