I can't believe that hasn't been done before, but I couldn't find any pathauto support for localizer for 4.7.2.x-dev. So I ported the existing pathauto support of i18n to localizer.

Benefits:
Pathauto will have the "lang" field as potential part of the generated alias. This allows aliases such as: [lang]/[title], with the language automatically set to be part of the alias.

Installation:
Save the code below as "/modules/pathauto/contrib/pathauto_node_localizer.inc".

--- pathauto_node_localizer.inc ---


function localizer_pathauto_node($op, $node=NULL) {
  switch ($op) {
    case 'placeholders':
      $placeholders = array();
      $placeholders[t('[lang]')] = t('Language code of the document');
      return $placeholders;
    case 'values':
      $results = array();
      $results[t('[lang]')] = _localizer_node_get_lang($node->nid);
      return $results;
    default:
      break;
  }
}

function _localizer_node_get_lang($nid, $default = '') {
  $lang = db_result(db_query('SELECT locale FROM {localizernode} WHERE nid = %d',$nid));
  return $lang ? $lang : $default ;
}

This has been tested on drupal 4.7.6 with the current dev versions of localizer and pathauto.

Comments

Bodo Maass’s picture

Note: As per drupal's coding conventions, the closing tage '?>' in the file above should be omitted.