Index: i18n.js
===================================================================
RCS file: i18n.js
diff -N i18n.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ i18n.js	11 Jan 2009 03:46:27 -0000
@@ -0,0 +1,17 @@
+// $Id: $
+
+/**
+ * Rewrite autocomplete inputs to pass the language of the node currently being
+ * edited in the path.
+ *
+ * This functionality ensures node autocompletes get suggestions for the node's
+ * language rather than the current interface language.
+ */
+Drupal.behaviors.i18n = function (context) {
+  if (Drupal.settings && Drupal.settings.i18n) {
+    $('form[id^=node-form]', context).find('input.autocomplete[value^=' + Drupal.settings.i18n.interface_path + ']').each(function () {
+      $(this).val($(this).val().replace(Drupal.settings.i18n.interface_path, Drupal.settings.i18n.content_path));
+    });
+  }
+};
+
Index: i18n.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/i18n/i18n.module,v
retrieving revision 1.41.2.27
diff -u -p -r1.41.2.27 i18n.module
--- i18n.module	10 Jan 2009 13:33:29 -0000	1.41.2.27
+++ i18n.module	11 Jan 2009 03:46:29 -0000
@@ -286,6 +286,58 @@ function i18n_user($op, &$edit, &$accoun
 }
 
 /**
+ * Implementation of hook_elements().
+ *
+ * Add a process callback for textfields.
+ */
+function i18n_elements() {
+  $type = array();
+  $type['textfield'] = array('#process' => array('i18n_textfield_process'));
+  return $type;
+}
+
+/**
+ * Process callback for textfield elements.
+ *
+ * When editing or translating a node, set Javascript to rewrite autocomplete
+ * paths to use the node language prefix rather than the current content one.
+ */
+function i18n_textfield_process($element) {
+  global $language;
+  static $sent = FALSE;
+
+  // Ensure we send the Javascript only once.
+  if (!$sent && isset($element['#autocomplete_path']) && !empty($element['#autocomplete_path'])) {
+    // Add a JS file for node forms.
+    // Determine if we are either editing or translating an existing node.
+    // We can't act on regular node creation because we don't have a specified
+    // node language.
+    $node_edit = $node = menu_get_object() && arg(2) == 'edit' && isset($node->language) && !empty($node->language);
+    $node_translate = arg(0) == 'node' && arg(1) == 'add' && !empty($_GET['translation']) && !empty($_GET['language']);
+    if ($node_edit || $node_translate) {
+      $node_language = $node_edit ? $node->language : $_GET['language'];
+      // Only needed if the node language is different from the interface one.
+      if ($node->language != $language->language) {
+        $languages = language_list();
+        if (isset($languages[$node_language])) {
+          drupal_add_js(drupal_get_path('module', 'i18n') . '/i18n.js');
+          // Pass the interface and content language base paths.
+          // Remove any trailing forward slash. Doing so prevents a mismatch
+          // that occurs when a language has no prefix and hence gets a path
+          // with a trailing forward slash.
+          $interface = rtrim(url('', array('absolute' => TRUE)), '/');
+          $content = rtrim(url('', array('absolute' => TRUE, 'language' => $languages[$node_language])), '/');
+          $data = array('interface_path' => $interface, 'content_path' => $content);
+          drupal_add_js(array('i18n' => $data), 'setting');
+        }
+      }
+    }
+    $sent = TRUE;
+  }
+  return $element;
+}
+
+/**
  * Simple i18n API
  */

