I want to use the following patterns in pathauto:

  • myCT All languages: pattern1
  • myCT neutral language: pattern2
  • myCT EN language: pattern2

So that all neutral (UND) and EN nodes of myCT have pattern2 and all other languages have pattern1. I'm using the ALL languages pattern for all other, as I have many other languages that should have the same pattern and I do not want to repeat it.

I'm using entity translation module for myCT.

When I create a node and save it having the default language (UND) and automatic path alias, pattern1 is always generated. I have to re-edit the node to have it get the correct pattern (for UND/neutral language), pattern2.

First of all, the pathauto_pattern_load_by_entity function (pathauto.module file) is called before the node creation, so the language of the node is always UND during creation of a node.

Second, trying to debug the pathauto module I can see the following:

function pathauto_pattern_load_by_entity($entity, $bundle = '', $language = LANGUAGE_NONE) {
  $patterns = &drupal_static(__FUNCTION__, array());

  $pattern_id = "$entity:$bundle:$language";
  if (!isset($patterns[$pattern_id])) {
    $variables = array();
    if ($language != LANGUAGE_NONE) {
      $variables[] = "pathauto_{$entity}_{$bundle}_{$language}_pattern";
    if ($bundle) {
      $variables[] = "pathauto_{$entity}_{$bundle}_pattern";
    $variables[] = "pathauto_{$entity}_pattern";

    foreach ($variables as $variable) {
      if ($pattern = trim(variable_get($variable, ''))) {

    $patterns[$pattern_id] = $pattern;

  return $patterns[$pattern_id];

So in the following lines it seems that it never takes into account the neutral language path.

if ($language != LANGUAGE_NONE) {
   $variables[] = "pathauto_{$entity}_{$bundle}_{$language}_pattern";

Shouldn't that if statement be removed? How is it possible to use the neutral language path otherwise?


Good point, I was thinking the same too.

Rather then the line to be removed there should be a check for LANGUAGE_NONE to set a pattern in the variables array for "und"-language. Then if not set the language specific pattern in the array.

I opened an issue and posted a patch, please check out https://www.drupal.org/node/2438745

  • Thank you for the patch. I hope it get included in the next release of Pathauto. – Maria Ioannidou Feb 26 '15 at 10:38

You can use the Pathauto i18n module:

This module provides functionality to create aliases for each language. Also this module will be helpful, if you use field translation and you want show node on all language with paths, different from node/nid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.