function Field::field_langcode

Return the language code of the language the field should be displayed in, according to the settings.

2 calls to Field::field_langcode()
Field::get_items in drupal/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php
Return an array of items for the field.
Field::process_entity in drupal/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php
Process an entity before using it for rendering.

File

drupal/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php, line 834
Definition of Drupal\field\Plugin\views\field\Field.

Class

Field
A field that displays fieldapi fields.

Namespace

Drupal\field\Plugin\views\field

Code

function field_langcode($entity_type, $entity) {
  if (field_is_translatable($entity_type, $this->field_info)) {
    $default_langcode = language_default()->langcode;
    $langcode = str_replace(array(
      '***CURRENT_LANGUAGE***',
      '***DEFAULT_LANGUAGE***',
    ), array(
      drupal_container()
        ->get(LANGUAGE_TYPE_CONTENT)->langcode,
      $default_langcode,
    ), $this->view->display_handler->options['field_language']);

    // Give the Field Language API a chance to fallback to a different language
    // (or LANGUAGE_NOT_SPECIFIED), in case the field has no data for the selected language.
    // field_view_field() does this as well, but since the returned language code
    // is used before calling it, the fallback needs to happen explicitly.
    $langcode = field_language($entity_type, $entity, $this->field_info['field_name'], $langcode);
    return $langcode;
  }
  else {
    return LANGUAGE_NOT_SPECIFIED;
  }
}