I'm currently working on a website with the locale and entity_translation modules enabled, and have noticed that aliases are saved with the language as und when the node has a different language such as "en".

I've looked at the pathauto_entity_language() function and I'm querying the order of the if statements within the function.

This is the original version:

function pathauto_entity_language($entity_type, $entity, $check_language_property = TRUE) {
  $langcode = NULL;

  if (function_exists('entity_language')) {
    $langcode = entity_language($entity_type, $entity);
  }
  elseif ($check_language_property && !empty($entity->language)) {
    $langcode = $entity->language;
  }

  return !empty($langcode) ? $langcode : LANGUAGE_NONE;
}

The entity_language function is stored within a core file - includes/common.inc - so that's always going to be present and the second condition isn't going to be executed.

Besides that, I think that it would be better to use the entity property as the first attempt, and only fallback to the entity type language when needed. This certainly seems to have fixed my issue.

I'll post a patch with my changes for review and clarification.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

opdavies created an issue. See original summary.

opdavies’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
787 bytes
opdavies’s picture

Small change to remove an extra condition.

opdavies’s picture

Status: Needs review » Closed (works as designed)

This seems to have been an issue with the entity_translate module.