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 14:17:52 -0000
@@ -3281,6 +3281,11 @@ function drupal_render_page($page) {
  * drupal_render(), for example from a database query, set
  * $elements['#sorted'] = TRUE to avoid sorting them a second time.
  *
+ * This function also supports rendering on the translation of an element
+ * in the current language. To take advantage of this, set
+ * $elements['#translatable'] = TRUE and ensure that children are keyed by
+ * language.
+ *
  * @param $elements
  *   The structured array describing the data to be rendered.
  * @return
@@ -3380,12 +3385,19 @@ function drupal_render(&$elements) {
  *   in to save another run of element_children().
  */
 function drupal_render_children($element, $children_keys = NULL) {
+  global $language;
+
   if ($children_keys === NULL) {
     $children_keys = element_children($element);
   }
   $output = '';
-  foreach ($children_keys as $key) {
-    $output .= drupal_render($element[$key]);
+  if (!empty($element['#translatable'])) {
+    $output .= drupal_render($element[$language->language]);
+  }
+  else {
+    foreach ($children_keys as $key) {
+      $output .= drupal_render($element[$key]);
+    }
   }
   return $output;
 }
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 14:17:54 -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,6 +185,11 @@ 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 ($field['translatable']) {
+    $field['cardinality'] = FIELD_CARDINALITY_UNLIMITED;
+  }
 
   $field += array(
     'cardinality' => 1,
@@ -555,4 +562,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.1
diff -u -p -r1.1 field_sql_storage.module
--- modules/field/modules/field_sql_storage/field_sql_storage.module	3 Feb 2009 17:30:11 -0000	1.1
+++ modules/field/modules/field_sql_storage/field_sql_storage.module	4 Feb 2009 14:17:54 -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,9 +227,19 @@ function field_sql_storage_field_storage
         foreach ($field['columns'] as $column => $attributes) {
           $item[$column] = $row->{_field_sql_storage_columnname($field_name, $column)};
         }
+        if ($field['translatable']) {
+
+          // Add the item to the field values for the entity, keyed by language.
+          $additions[$row->entity_id][$field_name][$item->language][] = $item;
 
-        // Add the item to the field values for the entity.
-        $additions[$row->entity_id][$field_name][] = $item;
+          // Add the #translatable property for this set of fields so it can be
+          // passed through render translation later.
+          $additions[$row->entity_id][$field_name]['#translatable'] = TRUE;
+        }
+        else {
+          // 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 +274,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 +291,7 @@ function field_sql_storage_field_storage
             'revision_id' => $vid,
             'bundle' => $bundle,
             'delta' => $delta,
+            'language' => $language,
           );
           foreach ($field['columns'] as $column => $attributes) {
             $record[_field_sql_storage_columnname($field_name, $column)] = isset($item[$column]) ? $item[$column] : NULL;
@@ -385,4 +404,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 14:17:56 -0000
@@ -538,6 +538,60 @@ 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 of content with #translate set to TRUE.
+   */
+  function testTranslationRendering() {
+    // First render a simple element with one value per language.
+    $elements = array(
+      'field_name' => array(
+        'en' => array('#markup' => 'English'),
+        'fr' => array('#markup' => 'French'),
+        '#translatable' => TRUE,
+      ),
+    );
+
+    // English is the default language, so we assume that for the purposes
+    // of testing.
+    $english_content = drupal_render($elements);
+    $this->assertTrue(strpos($english_content, 'English') !== FALSE, t('English field was rendered.'));
+    $this->assertFalse(strpos($english_content, 'French') !== FALSE, t('French field was not rendered'));
+
+    // Render a more complex element with multiple values per language.
+    $elements = array(
+      'field_name' => array(
+        'en' => array(
+          array('#markup' => 'English 1'),
+          array('#markup' => 'English 2'),
+        ),
+        'fr' =>  array(
+          array('#markup' => 'French 1'),
+          array('#markup' => 'French 2'),
+        ),
+        '#translatable' => TRUE,
+      ),
+    );
+    $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.'));
+
+    // Ensure that all elements are rendered when #translatable is FALSE.
+    $elements = array(
+      'field_name' => array(
+         'en' => array('#markup' => 'English'),
+         'fr' => array('#markup' => 'French'),
+         '#translatable' => FALSE,
+       ),
+    );
+    $content = drupal_render($elements);
+    $this->assertTrue(strpos($content, 'English') !== FALSE, t('English field was rendered.'));
+    $this->assertTrue(strpos($content, 'French') !== FALSE, t('French field was rendered'));
+
+  }
 }
 
 
