diff --git a/mappers/taxonomy.inc b/mappers/taxonomy.inc index 6fbe3e6..a8a5006 100644 --- a/mappers/taxonomy.inc +++ b/mappers/taxonomy.inc @@ -165,6 +165,13 @@ function taxonomy_feeds_set_target(FeedsSource $source, $entity, $target, array 'vid' => key($cache['allowed_vocabularies'][$target]), 'vocabulary_machine_name' => reset($cache['allowed_vocabularies'][$target]), ); + // Set language if the taxonomy is multilingual. + if ($language !== LANGUAGE_NONE) { + $info = entity_get_info('taxonomy_term'); + if (!empty($info['entity keys']['language'])) { + $term->{$info['entity keys']['language']} = $language; + } + } taxonomy_term_save($term); $tid = $term->tid; // Add to the list of allowed values. diff --git a/plugins/FeedsProcessor.inc b/plugins/FeedsProcessor.inc index 9e9d081..4ed85aa 100644 --- a/plugins/FeedsProcessor.inc +++ b/plugins/FeedsProcessor.inc @@ -717,10 +717,20 @@ abstract class FeedsProcessor extends FeedsPlugin { // If the target is a field and a mapping language is specified, empty the // value for the targeted language only. // In all other cases, just empty the target completely. + // @todo The definitive language to use is decided later, in + // ::mapToTarget(). In theory values for the wrong language could be + // emptied. if (isset($mapping['field_language']) && isset($fields[$target_name])) { + // First check if the specified language is available. + $languages = language_list('enabled'); + if (!isset($languages[1][$mapping['field_language']])) { + $mapping['field_language'] = LANGUAGE_NONE; + } + // Empty the target for the specified language. $target_item->{$target_name}[$mapping['field_language']] = array(); } else { + // Empty the whole target. $target_item->{$target_name} = NULL; } } diff --git a/tests/feeds_mapper_multilingual_fields.test b/tests/feeds_mapper_multilingual_fields.test index 28b6e29..a109f72 100644 --- a/tests/feeds_mapper_multilingual_fields.test +++ b/tests/feeds_mapper_multilingual_fields.test @@ -3,12 +3,6 @@ /** * @file * Contains FeedsMapperMultilingualFieldsTestCase. - * - * @todo - * - testAutocreatedTermLanguage() - * - Language for created terms is not set. - * - testClearOutValuesWithDisabledLanguage() - * - Values aren't cleared when configured language is no longer available. */ /** @@ -650,13 +644,15 @@ class FeedsMapperMultilingualFieldsTestCase extends FeedsMapperTestCase { } // Inspect availability of French values. - // @todo field_image has "la fayette_0.jpeg." $french = $this->getFrenchValues($node) + array( 'field_category' => array( 'expected' => 2, 'actual' => $node->field_category['fr'][0]['tid'], ), ); + // Since the image was placed on the node again, its file name is now + // "la fayette_0.jpeg." + $french['field_image']['expected'] = 'la fayette_0.jpeg'; foreach ($french as $field_name => $value) { $this->assertEqual($value['expected'], $value['actual'], format_string('The French field %field has the expected value (actual: @actual).', array('%field' => $field_name, '@actual' => $value['actual']))); }