Implement default language for node aliases.

You can read the details of the issue here:
  http://drupal.org/node/321848

The patch is from GoofyX http://drupal.org/user/47085, he should take credit
for it, my changes from his version are:

 * Show setting only when locale module is loaded
 * Simplify language list creation, just to use the same style used elsewhere
   in the module
 * Use the setting also in Bulk Update

Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>

Index: pathauto/pathauto.admin.inc
===================================================================
--- pathauto.orig/pathauto.admin.inc	2009-04-17 15:17:00.000000000 +0200
+++ pathauto/pathauto.admin.inc	2009-04-17 16:00:19.000000000 +0200
@@ -144,6 +144,17 @@
     '#description' => t('Words to strip out of the URL alias, separated by commas. Do not place punctuation in here and do not use WYSIWYG editors on this field.'),
   );
 
+  if (module_exists('locale')) {
+    $languages = array('' => t('Language neutral')) + locale_language_list('native');
+    $form['general']['pathauto_lang_save'] = array(
+      '#type' => 'select',
+      '#title' => t('Default alias language for nodes'),
+      '#description' => t('When creating a new alias, set its language to this one. Language neutral aliases will work for every lenguage.'),
+      '#default_value' => variable_get('pathauto_lang_save', language_default()->language),
+      '#options' => $languages
+    );
+  }
+
   $form['punctuation'] = array(
     '#type' => 'fieldset',
     '#weight' => $group_weight,
Index: pathauto/pathauto.module
===================================================================
--- pathauto.orig/pathauto.module	2009-04-17 15:17:08.000000000 +0200
+++ pathauto/pathauto.module	2009-04-17 15:39:02.000000000 +0200
@@ -241,7 +241,7 @@
           if (!isset($node->pathauto_perform_alias) || $node->pathauto_perform_alias) {
             $placeholders = pathauto_get_placeholders('node', $node);
             $src = "node/$node->nid";
-            $alias = pathauto_create_alias('node', $op, $placeholders, $src, $node->nid, $node->type, $node->language);
+            $alias = pathauto_create_alias('node', $op, $placeholders, $src, $node->nid, $node->type, variable_get('pathauto_lang_save', $node->language));
           }
         }
         break;
Index: pathauto/pathauto_node.inc
===================================================================
--- pathauto.orig/pathauto_node.inc	2009-04-17 15:41:27.000000000 +0200
+++ pathauto/pathauto_node.inc	2009-04-17 15:57:29.000000000 +0200
@@ -112,7 +112,7 @@
       }
       $placeholders = pathauto_get_placeholders('node', $node);
       $src = "node/$node->nid";
-      if (pathauto_create_alias('node', 'bulkupdate', $placeholders, $src, $node->nid, $node->type, $node->language)) {
+      if (pathauto_create_alias('node', 'bulkupdate', $placeholders, $src, $node->nid, $node->type, variable_get('pathauto_lang_save', $node->language))) {
         $count++;
       }
     }
