Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.129
diff -u -p -r1.129 locale.inc
--- includes/locale.inc	22 May 2007 07:42:36 -0000	1.129
+++ includes/locale.inc	22 May 2007 17:37:34 -0000
@@ -736,21 +736,53 @@ function locale_translate_edit_form($lid
   $languages = language_list();
   unset($languages['en']);
 
-  $result = db_query('SELECT DISTINCT s.source, t.translation, t.language FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid WHERE s.lid = %d', $lid);
+  $result = db_query('SELECT DISTINCT s.source, s.textgroup, s.location, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid WHERE s.lid = %d', $lid);
   $form = array();
   $form['translations'] = array('#tree' => TRUE);
+  $element = array();
   while ($translation = db_fetch_object($result)) {
     $orig = $translation->source;
 
-    // Approximate the number of rows in a textfield with a maximum of 10.
-    $rows = min(ceil(str_word_count($orig) / 12), 10);
-
-    $form['translations'][$translation->language] = array(
-      '#type' => 'textarea',
-      '#title' => $languages[$translation->language]->name,
-      '#default_value' => $translation->translation,
-      '#rows' => $rows,
-    );
+    // Create the form element required for this type of field.
+    if (empty($element)) {
+      switch ($translation->textgroup) {
+        case 'variable':
+          // Get list of variables and their form callbacks
+          $variables = module_invoke_all('locale', 'variables');
+          foreach ($variables as $callback => $names) {
+            // Found the set of variables where this one is defined.
+            if (in_array($translation->location, $names)) {
+              // Grab settings form and extract the part we need now.
+              $settings_form = $callback();
+              $element = $settings_form[$translation->location];
+            }
+          }
+          break;
+        
+        case 'default':
+          $element = array(
+            '#type' => 'textarea',
+          );
+      }
+    }
+    
+    // We actually have at least one translation
+    if (!empty($translation->language)) {
+      $form['translations'][$translation->language] = array_merge($element, array('#title' => $languages[$translation->language]->name));
+
+      switch ($translation->textgroup) {
+        case 'variable':
+          $form['translations'][$translation->language]['#default_value'] = unserialize($translation->translation);
+          break;
+      
+        default:
+          // Approximate the number of rows in a textfield with a maximum of 10.
+          $rows = min(ceil(str_word_count($orig) / 12), 10);
+          $form['translations'][$translation->language]['#rows'] = $rows;
+          $form['translations'][$translation->language]['#default_value'] = $translation->translation;
+          break;
+      }
+    }
     unset($languages[$translation->language]);
   }
 
@@ -768,11 +800,7 @@ function locale_translate_edit_form($lid
   );
 
   foreach ($languages as $langcode => $language) {
-    $form['translations'][$langcode] = array(
-      '#type' => 'textarea',
-      '#title' => t($language->name),
-      '#rows' => $rows,
-    );
+    $form['translations'][$langcode] = array_merge($element, array('#title' => t($language->name)));
   }
 
   $form['lid'] = array('#type' => 'value', '#value' => $lid);
@@ -787,13 +815,18 @@ function locale_translate_edit_form($lid
  */
 function locale_translate_edit_form_submit($form_values, $form, &$form_state) {
   $lid = $form_values['lid'];
+  
+  // We might need to serialize the value.
+  $textgroup = db_result(db_query("SELECT textgroup FROM {locales_source} WHERE lid = %d", $lid));
+  $serialize = ($textgroup == 'variable');
+  
   foreach ($form_values['translations'] as $key => $value) {
     $trans = db_fetch_object(db_query("SELECT translation FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $key));
     if (isset($trans->translation)) {
-      db_query("UPDATE {locales_target} SET translation = '%s' WHERE lid = %d AND language = '%s'", $value, $lid, $key);
+      db_query("UPDATE {locales_target} SET translation = '%s' WHERE lid = %d AND language = '%s'", $serialize ? serialize($value) : $value, $lid, $key);
     }
     else {
-      db_query("INSERT INTO {locales_target} (lid, translation, language) VALUES (%d, '%s', '%s')", $lid, $value, $key);
+      db_query("INSERT INTO {locales_target} (lid, translation, language) VALUES (%d, '%s', '%s')", $lid, $serialize? serialize($value) : $value, $key);
     }
   }
   drupal_set_message(t('The string has been saved.'));
@@ -1776,7 +1809,7 @@ function _locale_translate_seek() {
 
   // We have at least one criterion to match
   if ($query = _locale_translate_seek_query()) {
-    $join = "SELECT s.source, s.location, s.lid, s.textgroup, t.translation, t.language FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid ";
+    $join = "SELECT s.source, s.location, s.lid, s.textgroup, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid ";
 
     $arguments = array();
     // Compute LIKE section
Index: modules/locale/locale.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v
retrieving revision 1.174
diff -u -p -r1.174 locale.module
--- modules/locale/locale.module	22 May 2007 07:42:37 -0000	1.174
+++ modules/locale/locale.module	22 May 2007 17:37:35 -0000
@@ -480,3 +480,38 @@ function _locale_batch_import($filepath,
     $context['results'][] = $filepath;
   }
 }
+
+/**
+ * Update a variable source value for translation.
+ *
+ * @param $name
+ *   Variable name
+ * @param $value
+ *   Optional variable value. Will delete the variable
+ *   strings if NULL is passed.
+ */
+function locale_variable_update($name, $value = NULL) {
+  // Get a list of all variables defined.
+  $variables = module_invoke_all('locale', 'variables');
+  foreach ($variables as $callback => $names) {
+    // Found the set of variables where this one is defined.
+    if (in_array($name, $names)) {
+      if (!isset($value)) {
+        // TODO: delete (tricky, because we don't have a central variable default set, still)
+      }
+      else {
+        $lid = db_result(db_query("SELECT lid FROM {locales_source} WHERE textgroup = 'variable' AND location = '%s'", $name));
+        // We have this variable: modify value.
+        if ($lid) {
+          db_query("UPDATE {locales_source} SET source = '%s' WHERE lid = %d", serialize($value), $lid);
+        }
+        // No such variable: insert it.
+        else {
+          db_query("INSERT INTO {locales_source} (location, textgroup, source) VALUES ('%s', 'variable', '%s')", $name, serialize($value));
+        }
+      }
+      return TRUE;
+    }
+  }
+  return FALSE;
+}
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.480
diff -u -p -r1.480 system.module
--- modules/system/system.module	22 May 2007 05:52:17 -0000	1.480
+++ modules/system/system.module	22 May 2007 17:37:37 -0000
@@ -540,6 +540,22 @@ function _system_zonelist() {
   return $zones;
 }
 
+/**
+ * Implementation of hook_locale().
+ */
+function system_locale($op = 'groups') {
+  switch ($op) {
+    case 'groups':
+      return array('variable' => t('Site settings'));
+    case 'variables':
+      return array(
+        'system_site_information_settings' => array(
+          'site_name', 'site_slogan', 'site_mission', 'site_footer'
+        )
+      );
+  }
+}
+
 function system_site_information_settings() {
   $form['site_name'] = array(
     '#type' => 'textfield',
@@ -1259,12 +1275,16 @@ function system_settings_form_submit($fo
   foreach ($form_values as $key => $value) {
     if ($op == t('Reset to defaults')) {
       variable_del($key);
+      // Let locale module know that we updated variables.
+      module_invoke('locale', 'variable_update', $key);
     }
     else {
       if (is_array($value) && isset($form_values['array_filter'])) {
         $value = array_keys(array_filter($value));
       }
       variable_set($key, $value);
+      // Let locale module know that we updated variables.
+      module_invoke('locale', 'variable_update', $key, $value);
     }
   }
   if ($op == t('Reset to defaults')) {
