Index: l10n_community/l10n_community.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/l10n_community/Attic/l10n_community.css,v
retrieving revision 1.1.2.10.2.6
diff -u -p -r1.1.2.10.2.6 l10n_community.css
--- l10n_community/l10n_community.css	10 Sep 2009 09:15:03 -0000	1.1.2.10.2.6
+++ l10n_community/l10n_community.css	19 Oct 2009 06:55:29 -0000
@@ -166,6 +166,10 @@ table.l10n-server-translate label.option
     background: url(images/icon_copy.gif) no-repeat;
   }
 
+  .l10n-community-google-translate {
+    background: url(images/icon_google-translate.gif) no-repeat;
+  }
+
   .l10n-translate {
     background: url(images/icon_toolbox.gif) 0px 0px no-repeat;
   }
@@ -201,6 +205,7 @@ ul.l10n-community-strings li {
 ul.l10n-community-strings li .buttons {
   margin-left:-20px;
   float:left;
+  clear:both;
 }
 
 .l10n-community-string .original {
Index: l10n_community/l10n_community.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/l10n_community/Attic/l10n_community.js,v
retrieving revision 1.1.2.8.2.5
diff -u -p -r1.1.2.8.2.5 l10n_community.js
--- l10n_community/l10n_community.js	15 Oct 2009 08:46:40 -0000	1.1.2.8.2.5
+++ l10n_community/l10n_community.js	19 Oct 2009 06:55:29 -0000
@@ -33,6 +33,13 @@ l10nCommunity.init = function() {
     $('span.l10n-community-copy').click(function() {
       l10nCommunity.copyString(this);
     ;})
+    
+    if (Drupal.settings.l10n_google_translate) {
+      $('span.l10n-community-google-translate').click(function() {
+        //l10nCommunity.copyString(this);
+        l10nCommunity.googleTranslate(this);
+      ;})
+    }
 
     // Screw AJAX submit -- we'll just hard submit the form for now
     $('span.l10n-save').click(function() {
@@ -214,6 +221,87 @@ l10nCommunity.copySuggestion = function(
   return false;
 }
 
+/*
+ * Make a suggestion with Google Translate
+ */
+l10nCommunity.googleTranslate = function(elem) {
+  var item = $(elem).parents('li').find('div.string > div');
+  var parentlist = $(item).parents('ul.l10n-community-strings');
+  var original = $('.original', item).text();
+  var sid = item.attr('class').substring(7);
+  var service_errors = false;
+  
+  if (sid.indexOf('-') > 0) {
+    // Copying orignal plural string or active plural translation. We should
+    // get the original sid prefix and then copy the strings to the textareas.
+    sid = sid.split('-');
+    sid = sid[0];
+
+    /**
+     * While google.language.translate() is a asynchronous call and we cannot pass additional arguments
+     * to the callback, we cannot simply use the "i" counter because "i" may increments faster.
+     * As a workaround we will explicitly call the translator for the English variants #0 & #2 and
+     * then simply fill the next ones with the English variant #1.
+     */
+
+    // Variant #0.
+    source = $('.string-'+ sid +'-0 .original', parentlist).text();
+    google.language.translate(source, 'en', Drupal.settings.l10n_language, function(result) {
+      if (!result.error) {
+        $('#l10n-community-translation-'+ sid +'-0').val(result.translation);
+      }
+      else {
+        service_errors = true;
+      }
+    });
+    
+    // Variant #1.
+    source = $('.string-'+ sid +'-1 .original', parentlist).text();
+    google.language.translate(source, 'en', Drupal.settings.l10n_language, function(result) {
+      if (!result.error) {
+        // Fill #1 and other possible variants that this language may have.
+        for (i = 1; i < Drupal.settings.l10n_num_plurals; i++) {
+          $('#l10n-community-translation-'+ sid +'-'+ i).val(result.translation);
+        }
+      }
+      else {
+        service_errors = true;
+      }
+    });
+    
+  }
+  else {
+    // Use Google API to retrieve the translation
+    google.language.translate(original, 'en', Drupal.settings.l10n_language, function(result) {
+      if (!result.error) {
+        $('#l10n-community-translation-'+ sid).val(result.translation);
+      }
+      else {
+        service_errors = true;
+      }
+    });
+  }
+  
+  if (service_errors) {
+    return;
+  }
+  
+  // Show the editing controls.
+  $('#l10n-community-wrapper-' + sid).show();
+
+  // Check the suggestion box
+  $('#edit-'+ sid +'-translation-is-suggestion').attr('checked', true);
+
+  // Switch to translate pane. The pane is in the translation column, so
+  // if we are in the source column, we need to switch columns.
+  var parent = $(elem).parents('td.source, td.translation');
+  if (parent.get(0).className == 'source') {
+    parent = $(parent.get(0)).siblings();
+  }
+  var tool = $('.l10n-translate', parent);
+  l10nCommunity.switchPanes(tool, 'translate');
+}
+
 // Global killswitch
 if (Drupal.jsEnabled) {
   $(document).ready(l10nCommunity.init);
Index: l10n_community/l10n_community.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/l10n_community/Attic/l10n_community.module,v
retrieving revision 1.1.2.23.2.57
diff -u -p -r1.1.2.23.2.57 l10n_community.module
--- l10n_community/l10n_community.module	7 Oct 2009 18:21:36 -0000	1.1.2.23.2.57
+++ l10n_community/l10n_community.module	19 Oct 2009 06:55:29 -0000
@@ -1297,11 +1297,14 @@ function l10n_community_theme($existing,
       'arguments' => array('type' => NULL, 'class' => NULL, 'extras' => ''),
     ),
     'l10n_community_strings' => array(
-      'arguments' => array('items' => NULL, 'form' => TRUE),
+      'arguments' => array('items' => NULL, 'form' => TRUE, 'is_source' => TRUE),
     ),
     'l10n_community_copy_button' => array(
       'arguments' => array(),
     ),
+    'l10n_community_google_translate_button' => array(
+      'arguments' => array(),
+    ),
     // pages.inc
     'l10n_community_progress_columns' => array(
       'arguments' => array('sum' => NULL, 'translated' => NULL, 'has_suggestion' => NULL),
@@ -1375,6 +1378,10 @@ function theme_l10n_community_button($ty
       // Clear form button.
       $text = t('Clear');
       break;
+    case 'google-translate':
+      // Create suggestions with Google
+      $text = t('Google suggestion');
+      break;
   }
   return ' <span title="'. $text .'" class="'. $class .' l10n-button"'. (!empty($extras) ? (' '. $extras) : '') .'><b><b>'. $text .'</b></b></span>';
 }
@@ -1383,7 +1390,7 @@ function theme_l10n_community_button($ty
  * Theme a list of translatable strings. Adds a copy button to each string
  * for quickly copying its source text into a translation form.
  */
-function theme_l10n_community_strings($items, $form = TRUE) {
+function theme_l10n_community_strings($items, $form = TRUE, $is_source = FALSE) {
   $output = "<ul class='l10n-community-strings'>";
   foreach ($items as $i => $item) {
     $output .= "<li class='clear-block'>";
@@ -1392,6 +1399,9 @@ function theme_l10n_community_strings($i
       // For plurals, only the first item will have the copy button, but will copy
       // all the values into the form.
       $output .= "<div class='buttons'>". theme('l10n_community_copy_button') ."</div>";
+      if ($is_source && variable_get('l10n_community_google_translate', TRUE)) {
+        $output .= '<div class="buttons">'. theme('l10n_community_google_translate_button') .'</div>';
+      }
     }
     $output .= "<div class='string'>". $item ."</div>";
     $output .= "</li>";
@@ -1408,6 +1418,13 @@ function theme_l10n_community_copy_butto
 }
 
 /**
+ * Google suggestion button
+ */
+function theme_l10n_community_google_translate_button() {
+  return theme('l10n_community_button', 'google-translate', 'l10n-community-google-translate');
+}
+
+/**
  * Format string for display. Takes plurals into account.
  */
 function l10n_community_format_string($value, $rich_markup = TRUE) {
Index: l10n_community/translate.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/l10n_community/Attic/translate.inc,v
retrieving revision 1.1.2.7.2.21
diff -u -p -r1.1.2.7.2.21 translate.inc
--- l10n_community/translate.inc	15 Oct 2009 08:46:40 -0000	1.1.2.7.2.21
+++ l10n_community/translate.inc	19 Oct 2009 06:55:29 -0000
@@ -46,6 +46,10 @@ function l10n_community_translate_page($
     // For users with some permission, display the form.
     drupal_add_js(drupal_get_path('module', 'l10n_community') .'/l10n_community.js');
     drupal_set_title(t('Translate to @language', array('@language' => $languages[$langcode]->name)));
+    if (variable_get('l10n_community_google_translate', TRUE)) {
+      drupal_set_html_head('<script type="text/javascript" src="http://www.google.com/jsapi" /></script>');
+      drupal_set_html_head("\n<script type=\"text/javascript\">\ngoogle.load(\"language\", \"1\");\n</script>\n");
+    }
     $output .= drupal_get_form('l10n_community_translate_form', $strings, $languages[$langcode], $filters, $perm);
   }
   return $output;
@@ -304,7 +308,7 @@ function l10n_community_translate_form(&
     // A toolbox which displays action icons on each string editor fieldset.
     $toolbox = theme('l10n_community_button', 'translate', 'l10n-translate active');
     $toolbox .= theme('l10n_community_button', 'lookup', 'l10n-lookup');
-    $toolbox .= $string->has_suggestion ? theme('l10n_community_button', 'has-suggestion', 'l10n-suggestions') : "";
+    $toolbox .= $string->has_suggestion ? theme('l10n_community_button', 'has-suggestion', 'l10n-suggestions') : '';
     $toolbox = "<div class='toolbox'>$toolbox</div>";
     $form[$string->sid]['toolbox'] = array(
       '#type' => 'markup',
@@ -323,7 +327,7 @@ function l10n_community_translate_form(&
     foreach ($string_parts as $delta => &$part) {
       $part = l10n_community_format_text($part, $string->sid, (count($string_parts) > 1) ? $delta : NULL);
     }
-    $source = theme('l10n_community_strings', $string_parts);
+    $source = theme('l10n_community_strings', $string_parts, TRUE, TRUE);
     $source .= theme('l10n_community_in_context', $string);
 
     $form[$string->sid]['source'] = array(
@@ -450,7 +454,9 @@ function l10n_community_translate_form(&
       'l10n_approve_callback' => url('translate/approve/'),
       'l10n_decline_callback' => url('translate/decline/'),
       'l10n_form_token_path'  => variable_get('clean_url', '0') ? '?form_token=' : '&form_token=',
-      'l10n_num_plurals'      => $language->plurals
+      'l10n_num_plurals'      => $language->plurals,
+      'l10n_language'         => $language->language,
+      'l10n_google_translate' => variable_get('l10n_community_google_translate', TRUE),
     ),
     'setting'
   );
