Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.863
diff -u -p -r1.863 common.inc
--- includes/common.inc	3 Feb 2009 18:55:29 -0000	1.863
+++ includes/common.inc	4 Feb 2009 23:02:09 -0000
@@ -3391,6 +3391,18 @@ function drupal_render_children($element
 }
 
 /**
+ * Replace the contents of an element with translations in the current language.
+ *
+ * This can be used as #pre_render callback when your $elements array contains
+ * a 'translations' key, and allows for only the translation for the current
+ * language to be rendered.
+ */
+function drupal_filter_translation($elements) {
+  global $language;
+  return isset($elements['translations'][$language->language]) ? $elements['translations'][$language->language] : array();
+}
+
+/**
  * Function used by uasort to sort structured arrays by weight.
  */
 function element_sort($a, $b) {
Index: modules/field/field.crud.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.crud.inc,v
retrieving revision 1.1
diff -u -p -r1.1 field.crud.inc
--- modules/field/field.crud.inc	3 Feb 2009 17:30:11 -0000	1.1
+++ modules/field/field.crud.inc	4 Feb 2009 23:02:10 -0000
@@ -39,6 +39,8 @@ class FieldException extends Exception {
  * - cardinality (integer)
  *     The number of values the field can hold.  Legal values are any
  *     positive integer or FIELD_CARDINALITY_UNLIMITED.
+ * - translatable (integer)
+       Whether the field is translatable.
  * - locked (integer)
  *     TODO: undefined.
  * - module (string, read-only)
@@ -183,8 +185,14 @@ function field_create_field($field) {
   if (!empty($prior_field)) {
     throw new FieldException(t('Attempt to create field name %name which already exists.', array('%name' => $field['field_name'])));
   }
+  // Translatable fields are set to FIELD_CARDINALITY_UNLIMITED to account for
+  // data being stored in any variable number of languages.
+  if (!empty($field['translatable'])) {
+    $field['cardinality'] = FIELD_CARDINALITY_UNLIMITED;
+  }
 
   $field += array(
+    'translatable' => 0,
     'cardinality' => 1,
     'locked' => FALSE,
     'settings' => array(),
@@ -555,4 +563,4 @@ function field_delete_instance($field_na
 
 /**
  * @} End of "defgroup field_crud".
- */
\ No newline at end of file
+ */
Index: modules/field/modules/field_sql_storage/field_sql_storage.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/field_sql_storage/field_sql_storage.module,v
retrieving revision 1.2
diff -u -p -r1.2 field_sql_storage.module
--- modules/field/modules/field_sql_storage/field_sql_storage.module	4 Feb 2009 20:27:58 -0000	1.2
+++ modules/field/modules/field_sql_storage/field_sql_storage.module	4 Feb 2009 23:02:11 -0000
@@ -128,7 +128,15 @@ function _field_sql_storage_schema($fiel
         'not null' => TRUE,
         'description' => 'The sequence number for this data item, used for multi-value fields',
       ),
+      'language' => array(
+        'type' => 'varchar',
+        'length' => 32,
+        'not null' => TRUE,
+        'default' => '',
+        'description' => 'The language for this data item.',
+      ),
     ),
+
     'primary key' => array('etid', 'entity_id', 'deleted', 'delta'),
     // TODO : index on 'bundle'
   );
@@ -219,7 +227,11 @@ function field_sql_storage_field_storage
         foreach ($field['columns'] as $column => $attributes) {
           $item[$column] = $row->{_field_sql_storage_columnname($field_name, $column)};
         }
-
+        if (!empty($field['translatable'])) {
+          // Add the item to the translations for the field, keyed by language.
+          $additions[$row->entity_id][$field_name]['#pre_render'] = array('drupal_filter_translation');
+          $additions[$row->entity_id][$field_name]['translations'][$item->language][] = $item;
+        }
         // Add the item to the field values for the entity.
         $additions[$row->entity_id][$field_name][] = $item;
         $delta_count[$row->entity_id][$field_name]++;
@@ -256,7 +268,7 @@ function field_sql_storage_field_storage
 
       if ($object->$field_name) {
         // Prepare the multi-insert query.
-        $columns = array('etid', 'entity_id', 'revision_id', 'bundle', 'delta');
+        $columns = array('etid', 'entity_id', 'revision_id', 'bundle', 'delta', 'language');
         foreach ($field['columns'] as $column => $attributes) {
           $columns[] = _field_sql_storage_columnname($field_name, $column);
         }
@@ -273,6 +285,7 @@ function field_sql_storage_field_storage
             'revision_id' => $vid,
             'bundle' => $bundle,
             'delta' => $delta,
+            'language' => !empty($language) ? $language : '',
           );
           foreach ($field['columns'] as $column => $attributes) {
             $record[_field_sql_storage_columnname($field_name, $column)] = isset($item[$column]) ? $item[$column] : NULL;
@@ -385,4 +398,4 @@ function field_sql_storage_field_storage
       ->condition('bundle', $bundle_old)
       ->execute();
   }
-}
\ No newline at end of file
+}
Index: modules/simpletest/tests/common.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v
retrieving revision 1.25
diff -u -p -r1.25 common.test
--- modules/simpletest/tests/common.test	31 Jan 2009 19:07:45 -0000	1.25
+++ modules/simpletest/tests/common.test	4 Feb 2009 23:02:12 -0000
@@ -538,6 +538,41 @@ class DrupalRenderUnitTestCase extends D
     // The lowest weight element should appear last in $output.
     $this->assertTrue(strpos($output, $second) > strpos($output, $first), t('Elements were sorted correctly by weight'));
   }
+
+  /**
+   * Test rendering with drupal_filter_translation() as a #pre_render callback.
+   */
+  function testPreRenderCallback() {
+
+    // Render an element with multiple values per language.
+    $elements = array(
+      'field_name' => array(
+        array('#markup' => 'English 1'),
+        array('#markup' => 'English 2'),
+        array('#markup' => 'French 1'),
+        array('#markup' => 'French 2'),
+        '#pre_render' => array('drupal_filter_translation'),
+        'translations' => array(
+          'en' => array(
+            array('#markup' => 'English 1'),
+            array('#markup' => 'English 2'),
+          ),
+          'fr' => array(
+            array('#markup' => 'French 1'),
+            array('#markup' => 'French 2'),
+          ),
+        ),
+      ),
+    );
+
+    // English is the default language, so assume this for the purposes of testing.
+    $english_content = drupal_render($elements);
+
+    $this->assertTrue(strpos($english_content, 'English 1') !== FALSE, t('English field was rendered.'));
+    $this->assertTrue(strpos($english_content, 'English 2') !== FALSE, t('English field was rendered.'));
+    $this->assertFalse(strpos($english_content, 'French 1') !== FALSE, t('French content was not rendered.'));
+    $this->assertFalse(strpos($english_content, 'French 2') !== FALSE, t('French content was not rendered.'));
+  }
 }
 
 
