You are here

public function views_handler_field_field::field_language in Views (for Drupal 7) 7.3

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

2 calls to views_handler_field_field::field_language()
views_handler_field_field::get_value in modules/field/views_handler_field_field.inc
Get the value that's supposed to be rendered.
views_handler_field_field::set_items in modules/field/views_handler_field_field.inc
Return an array of items for the field.

File

modules/field/views_handler_field_field.inc, line 966
Definition of views_handler_field_field.

Class

views_handler_field_field
A field that displays fieldapi fields.

Code

public function field_language($entity_type, $entity) {
  global $language_content;
  if (field_is_translatable($entity_type, $this->field_info)) {
    $default_language = language_default('language');
    $language = str_replace(array(
      '***CURRENT_LANGUAGE***',
      '***DEFAULT_LANGUAGE***',
    ), array(
      $language_content->language,
      $default_language,
    ), $this->view->display_handler->options['field_language']);

    // Give the Field Language API a chance to fallback to a different
    // language (or LANGUAGE_NONE), 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.
    $language = field_language($entity_type, $entity, $this->field_info['field_name'], $language);
    return $language;
  }
  else {
    return LANGUAGE_NONE;
  }
}