summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfago2012-12-25 21:09:39 (GMT)
committer fago2012-12-25 21:09:39 (GMT)
commit6fd5aa2a678de549f6e6e674c2243bd73e63145e (patch)
tree9f672afb44b986f295ab7a89272e498dc4d3a7d9
parentd73f3dcfd2567fa7a9293f3173941d03fe542c96 (diff)
Issue #1376126: Fix language handling for translatable fields.7.x-1.0
-rw-r--r--modules/callbacks.inc9
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/callbacks.inc b/modules/callbacks.inc
index a7df7af..dca9e1d 100644
--- a/modules/callbacks.inc
+++ b/modules/callbacks.inc
@@ -509,8 +509,13 @@ function entity_metadata_field_verbatim_set($entity, $name, $items, $langcode, $
*/
function entity_metadata_field_get_language($entity_type, $entity, $field, $langcode = LANGUAGE_NONE, $fallback = FALSE) {
// Try to figure out the default language used by the entity.
- // @todo: Update once http://drupal.org/node/1260640 has been fixed.
- $default_langcode = !empty($entity->language) ? $entity->language : LANGUAGE_NONE;
+ // With Drupal >= 7.15 we can use entity_language().
+ if (function_exists('entity_language')) {
+ $default_langcode = entity_language($entity_type, $entity);
+ }
+ else {
+ $default_langcode = !empty($entity->language) ? $entity->language : LANGUAGE_NONE;
+ }
// Determine the right language to use.
if ($default_langcode != LANGUAGE_NONE && field_is_translatable($entity_type, $field)) {