Return the language code of the language the field should be displayed in, according to the settings.
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;
}
}