Hello there,
I would like to create some alias for all the languages, not just for the language that the user is using in that moment. For that, I have been investigating with the pathauto and there is not possibility (as far as I know).

First of all, I have checked in the UI (admin/config/search/path/patterns) and there is no way to do it. But then you can change the alias (admin/config/search/path/edit/ID_NUMBER) and change the language to All Languages.
I have tried also implementing the hook_pathauto_alias_alter hook. Unfortunately, this hook is designed to just change the alias, not the context. In my implementation of this hook, I have pass by reference the $context variable, and I have change the language in there ($context->language). But in the function pathauto_create_alias you don't hope an altered $context, so you don't process it and, therefore, my changes are lost.
So, I think that the easiest way for achieve what I want is that you add this line of code:
$language = $context['language'];
just after
drupal_alter('pathauto_alias', $alias, $context); in the pathauto_create_alias function.
So, it would look like:

...
  // Allow other modules to alter the alias.
  $context = array(
    'module' => $module,
    'op' => $op,
    'source' => $source,
    'data' => $data,
    'type' => $type,
    'language' => $language,
    'pattern' => $pattern,
  );
  drupal_alter('pathauto_alias', $alias, $context);
  $language = $context['language'];
  // If we have arrived at an empty string, discontinue.
  if (!drupal_strlen($alias)) {
    return '';
  }
...

Maybe you could reconsider this and also let other variables in the $context be altered.
And, of course, you should declare your hook as:

function hook_pathauto_alias_alter(&$alias, array &$context) {
}

Thanks!

Comments

Dave Reid’s picture

Status: Active » Fixed

This has now been fixed with http://drupalcode.org/project/pathauto.git/commit/4d8a96d - you can now alter $context['source'] and $context['language'] by reference from the hook. I've also added better documentation for that hook.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jan.ptacek’s picture

Hi, first of all: I love pathauto,

the thing is, default settings where pathauto assigns a language to aliases
(is efficient, I realize) but leads to unexpected 404 errors on multi-language sites and costs newbies hours to days to resolve (through the hook or akamaus sandbox)

in my personal case I lost a client due this :(

please reconsider the behaviour
best Jan