diff --git a/core/modules/aggregator/aggregator.install b/core/modules/aggregator/aggregator.install index 0f52e71..7949a9a 100644 --- a/core/modules/aggregator/aggregator.install +++ b/core/modules/aggregator/aggregator.install @@ -133,6 +133,13 @@ function aggregator_schema() { 'default' => '', 'description' => 'Title of the feed.', ), + 'langcode' => array( + 'description' => 'The {language}.langcode of this feed.', + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => '', + ), 'url' => array( 'type' => 'text', 'not null' => TRUE, @@ -232,6 +239,13 @@ function aggregator_schema() { 'default' => '', 'description' => 'Title of the feed item.', ), + 'langcode' => array( + 'description' => 'The {language}.langcode of this feed item.', + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => '', + ), 'link' => array( 'type' => 'text', 'not null' => TRUE, @@ -293,3 +307,31 @@ function aggregrator_update_8000() { 'aggregator_category_selector' => 'source.category_selector', )); } + +/** + * Adds the langcode field to {aggregator_item} and {aggregator_feed}. + */ +function aggregator_update_8001() { + // Add the field. + db_add_field('aggregator_feed', 'langcode', array( + 'description' => 'The {language}.langcode of this feed.', + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => '', + )); + db_add_field('aggregator_item', 'langcode', array( + 'description' => 'The {language}.langcode of this feed item.', + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => '', + )); + // Set langcode to LANGUAGE_DEFAULT. + db_update('aggregator_feed') + ->fields(array('langcode' => LANGUAGE_DEFAULT)) + ->execute(); + db_update('aggregator_item') + ->fields(array('langcode' => LANGUAGE_DEFAULT)) + ->execute(); +} \ No newline at end of file diff --git a/core/modules/aggregator/aggregator.processor.inc b/core/modules/aggregator/aggregator.processor.inc index 54ae7a5..10b52f1 100644 --- a/core/modules/aggregator/aggregator.processor.inc +++ b/core/modules/aggregator/aggregator.processor.inc @@ -49,7 +49,7 @@ function aggregator_aggregator_process($feed) { $entry = reset($entry); } else { - $entry = entity_create('aggregator_item', array()); + $entry = entity_create('aggregator_item', array('langcode' => $feed->language()->langcode)); } if ($item['timestamp']) { $entry->timestamp->value = $item['timestamp']; diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php index 12a156b..97fb698 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php @@ -30,6 +30,14 @@ public function form(array $form, array &$form_state, EntityInterface $feed) { '#description' => t('The name of the feed (or the name of the website providing the feed).'), '#required' => TRUE, ); + + $form['langcode'] = array( + '#title' => t('Language'), + '#type' => 'language_select', + '#default_value' => $feed->language()->langcode, + '#languages' => LANGUAGE_ALL, + ); + $form['url'] = array( '#type' => 'url', '#title' => t('URL'), diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageController.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageController.php index 6268201..d8c052c 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageController.php @@ -127,6 +127,11 @@ public function baseFieldDefinitions() { 'description' => t('The title of the feed.'), 'type' => 'string_field', ); + $fields['langcode'] = array( + 'label' => t('Language code'), + 'description' => t('The feed language code.'), + 'type' => 'language_field', + ); $fields['url'] = array( 'label' => t('URL'), 'description' => t('The URL to the feed.'), diff --git a/core/modules/aggregator/lib/Drupal/aggregator/ItemStorageController.php b/core/modules/aggregator/lib/Drupal/aggregator/ItemStorageController.php index 87479ed..69876ab 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/ItemStorageController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/ItemStorageController.php @@ -87,6 +87,11 @@ public function baseFieldDefinitions() { 'description' => t('The title of the feed item.'), 'type' => 'string_field', ); + $fields['langcode'] = array( + 'label' => t('Language code'), + 'description' => t('The feed item language code.'), + 'type' => 'language_field', + ); $fields['link'] = array( 'label' => t('Link'), 'description' => t('The link of the feed item.'), diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Feed.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Feed.php index c53558e..916931d 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Feed.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Feed.php @@ -51,6 +51,13 @@ class Feed extends EntityNG implements ContentEntityInterface { public $title; /** + * The feed language code. + * + * @var \Drupal\Core\Entity\Field\FieldInterface + */ + public $langcode; + + /** * URL to the feed. * * @var \Drupal\Core\Entity\Field\FieldInterface diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Item.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Item.php index cc780bd..8f6468c 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Item.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Core/Entity/Item.php @@ -57,6 +57,13 @@ class Item extends EntityNG implements ContentEntityInterface { public $title; /** + * The feed language code. + * + * @var \Drupal\Core\Entity\Field\FieldInterface + */ + public $langcode; + + /** * Link to the feed item. * * @var \Drupal\Core\Entity\Field\FieldInterface