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 3 Feb 2009 22:24:11 -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 3 Feb 2009 22:24:12 -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,14 @@ function field_sql_storage_field_storage foreach ($field['columns'] as $column => $attributes) { $item[$column] = $row->{_field_sql_storage_columnname($field_name, $column)}; } - - // Add the item to the field values for the entity. - $additions[$row->entity_id][$field_name][] = $item; + 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; + } + 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 +269,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 +286,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 +399,4 @@ function field_sql_storage_field_storage ->condition('bundle', $bundle_old) ->execute(); } -} \ No newline at end of file +}