From 83fd59dc7c7b7f1b1081f257739c3bb3598c9cb0 Mon Sep 17 00:00:00 2001 From: Alex Barth <alex_b@53995.no-reply.drupal.org> Date: Wed, 28 Apr 2010 20:45:37 +0000 Subject: [PATCH] #776972 lyricnz: Messages use plural when describing single item. --- CHANGELOG.txt | 1 + feeds_defaults/tests/feeds_defaults.test | 2 +- plugins/FeedsDataProcessor.inc | 8 ++++---- plugins/FeedsFeedNodeProcessor.inc | 4 ++-- plugins/FeedsNodeProcessor.inc | 6 +++--- plugins/FeedsTermProcessor.inc | 16 ++++++++++++---- plugins/FeedsUserProcessor.inc | 14 +++++++++++--- tests/feeds.test | 2 +- 8 files changed, 35 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index adb52e1a..ced6d5ea 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,7 @@ Feeds 6.x 1.0 xxxxxxxxxxxxxxxxxxxx ---------------------------------- +- #776972 lyricnz: Messages use plural when describing single item. - #701390 frega, morningtime, Mixologic, alex_b et. al.: Fix RSS 1.0 parsing and add basic test framework for common_syndication_parser. - #781058 blakehall: Create teaser for imported nodes. NOTE: this may mean that diff --git a/feeds_defaults/tests/feeds_defaults.test b/feeds_defaults/tests/feeds_defaults.test index 17e0e4d5..4c65b3b8 100644 --- a/feeds_defaults/tests/feeds_defaults.test +++ b/feeds_defaults/tests/feeds_defaults.test @@ -457,7 +457,7 @@ class FeedsDefaultsUserTestCase extends FeedsDefaultsTestCase { // Assert result. $this->assertText('Created 4 users.'); // 1 user has an invalid email address. - $this->assertText('There were 1 users that could not be imported because either their name or their email was empty or not valid. Check import data and mapping settings on User processor.'); + $this->assertText('There was 1 user that could not be imported because either their name or their email was empty or not valid. Check import data and mapping settings on User processor.'); $this->drupalGet('admin/user/user'); $this->assertText('Morticia'); $this->assertText('Fester'); diff --git a/plugins/FeedsDataProcessor.inc b/plugins/FeedsDataProcessor.inc index 3bad4313..2f1afcd4 100644 --- a/plugins/FeedsDataProcessor.inc +++ b/plugins/FeedsDataProcessor.inc @@ -42,10 +42,10 @@ class FeedsDataProcessor extends FeedsProcessor { // Set messages. if ($inserted) { - drupal_set_message(t('Created !number items.', array('!number' => $inserted))); + drupal_set_message(format_plural($inserted, 'Created !number item.', 'Created !number items.', array('!number' => $inserted))); } elseif ($updated) { - drupal_set_message(t('Updated !number items.', array('!number' => $updated))); + drupal_set_message(format_plural($updated, 'Updated !number item.', 'Updated !number items.', array('!number' => $updated))); } else { drupal_set_message(t('There are no new items.')); @@ -64,7 +64,7 @@ class FeedsDataProcessor extends FeedsProcessor { 'feed_nid' => $source->feed_nid, ); $num = $this->handler()->delete($clause); - drupal_set_message(t('Deleted !number items.', array('!number' => $num))); + drupal_set_message(format_plural($num, 'Deleted !number item.', 'Deleted !number items.', array('!number' => $num))); return FEEDS_BATCH_COMPLETE; } @@ -85,7 +85,7 @@ class FeedsDataProcessor extends FeedsProcessor { ), ); $num = $this->handler()->delete($clause); - drupal_set_message(t('Expired !number records from !table.', array('!number' => $num, '!table' => $this->tableName()))); + drupal_set_message(format_plural($num, 'Expired !number record from !table.', 'Expired !number records from !table.', array('!number' => $num, '!table' => $this->tableName()))); return FEEDS_BATCH_COMPLETE; } diff --git a/plugins/FeedsFeedNodeProcessor.inc b/plugins/FeedsFeedNodeProcessor.inc index 32b441e1..120bcba2 100644 --- a/plugins/FeedsFeedNodeProcessor.inc +++ b/plugins/FeedsFeedNodeProcessor.inc @@ -45,10 +45,10 @@ class FeedsFeedNodeProcessor extends FeedsProcessor { // Set messages. if ($batch->created) { - drupal_set_message(t('Created !number !type nodes.', array('!number' => $batch->created, '!type' => $this->config['content_type']))); + drupal_set_message(format_plural($batch->created, 'Created !number !type node.', 'Created !number !type nodes.', array('!number' => $batch->created, '!type' => $this->config['content_type']))); } elseif ($batch->updated) { - drupal_set_message(t('Updated !number !type nodes.', array('!number' => $batch->updated, '!type' => $this->config['content_type']))); + drupal_set_message(format_plural($batch->updated, 'Updated !number !type node.', 'Updated !number !type nodes.', array('!number' => $batch->updated, '!type' => $this->config['content_type']))); } else { drupal_set_message(t('There is no new content.')); diff --git a/plugins/FeedsNodeProcessor.inc b/plugins/FeedsNodeProcessor.inc index 8c95253f..3212827b 100644 --- a/plugins/FeedsNodeProcessor.inc +++ b/plugins/FeedsNodeProcessor.inc @@ -81,10 +81,10 @@ class FeedsNodeProcessor extends FeedsProcessor { // Set messages. if ($batch->created) { - drupal_set_message(t('Created !number !type nodes.', array('!number' => $batch->created, '!type' => node_get_types('name', $this->config['content_type'])))); + drupal_set_message(format_plural($batch->created, 'Created !number !type node.', 'Created !number !type nodes.', array('!number' => $batch->created, '!type' => node_get_types('name', $this->config['content_type'])))); } elseif ($batch->updated) { - drupal_set_message(t('Updated !number !type nodes.', array('!number' => $batch->updated, '!type' => node_get_types('name', $this->config['content_type'])))); + drupal_set_message(format_plural($batch->updated, 'Updated !number !type node.', 'Updated !number !type nodes.', array('!number' => $batch->updated, '!type' => node_get_types('name', $this->config['content_type'])))); } else { drupal_set_message(t('There is no new content.')); @@ -112,7 +112,7 @@ class FeedsNodeProcessor extends FeedsProcessor { // Set message. drupal_get_messages('status'); if ($batch->deleted) { - drupal_set_message(t('Deleted !number nodes.', array('!number' => $batch->deleted))); + drupal_set_message(format_plural($batch->deleted, 'Deleted !number node.', 'Deleted !number nodes.', array('!number' => $batch->deleted))); } else { drupal_set_message(t('There is no content to be deleted.')); diff --git a/plugins/FeedsTermProcessor.inc b/plugins/FeedsTermProcessor.inc index 6f1dd539..31ef7ee5 100644 --- a/plugins/FeedsTermProcessor.inc +++ b/plugins/FeedsTermProcessor.inc @@ -58,13 +58,21 @@ class FeedsTermProcessor extends FeedsProcessor { $vocabularies = taxonomy_get_vocabularies(); $vocabulary = $vocabularies[$this->config['vocabulary']]; if ($no_name) { - drupal_set_message(t('There were !number terms that could not be imported because their name was empty. Check mapping settings on Taxomy term processor.', array('!number' => $no_name)), 'error'); + drupal_set_message( + format_plural( + $no_name, + 'There was !number term that could not be imported because their name was empty. Check mapping settings on Taxomy term processor.', + 'There were !number terms that could not be imported because their name was empty. Check mapping settings on Taxomy term processor.', + array('!number' => $no_name) + ), + 'error' + ); } if ($created) { - drupal_set_message(t('Created !number terms in !vocabulary.', array('!number' => $created, '!vocabulary' => $vocabulary->name))); + drupal_set_message(format_plural($created, 'Created !number term in !vocabulary.', 'Created !number terms in !vocabulary.', array('!number' => $created, '!vocabulary' => $vocabulary->name))); } elseif ($updated) { - drupal_set_message(t('Updated !number terms in !vocabulary.', array('!number' => $updated, '!vocabulary' => $vocabulary->name))); + drupal_set_message(format_plural($updated, 'Updated !number term in !vocabulary.', 'Updated !number terms in !vocabulary.', array('!number' => $updated, '!vocabulary' => $vocabulary->name))); } else { drupal_set_message(t('There are no new terms.')); @@ -90,7 +98,7 @@ class FeedsTermProcessor extends FeedsProcessor { $vocabularies = taxonomy_get_vocabularies(); $vocabulary = $vocabularies[$this->config['vocabulary']]; if ($deleted) { - drupal_set_message(t('Deleted !number terms from !vocabulary.', array('!number' => $deleted, '!vocabulary' => $vocabulary->name))); + drupal_set_message(format_plural($deleted, 'Deleted !number term from !vocabulary.', 'Deleted !number terms from !vocabulary.', array('!number' => $deleted, '!vocabulary' => $vocabulary->name))); } else { drupal_set_message(t('No terms to be deleted.')); diff --git a/plugins/FeedsUserProcessor.inc b/plugins/FeedsUserProcessor.inc index 9d3ae4ba..04afee0a 100644 --- a/plugins/FeedsUserProcessor.inc +++ b/plugins/FeedsUserProcessor.inc @@ -61,13 +61,21 @@ class FeedsUserProcessor extends FeedsProcessor { // Set messages. if ($failed) { - drupal_set_message(t('There were !number users that could not be imported because either their name or their email was empty or not valid. Check import data and mapping settings on User processor.', array('!number' => $failed)), 'error'); + drupal_set_message( + format_plural( + $failed, + 'There was !number user that could not be imported because either their name or their email was empty or not valid. Check import data and mapping settings on User processor.', + 'There were !number users that could not be imported because either their name or their email was empty or not valid. Check import data and mapping settings on User processor.', + array('!number' => $failed) + ), + 'error' + ); } if ($created) { - drupal_set_message(t('Created !number users.', array('!number' => $created))); + drupal_set_message(format_plural($created, 'Created !number user.', 'Created !number users.', array('!number' => $created))); } elseif ($updated) { - drupal_set_message(t('Updated !number users.', array('!number' => $updated))); + drupal_set_message(format_plural($updated, 'Updated !number user.', 'Updated !number users.', array('!number' => $updated))); } else { drupal_set_message(t('There are no new users.')); diff --git a/tests/feeds.test b/tests/feeds.test index 925b2fd5..269bb586 100644 --- a/tests/feeds.test +++ b/tests/feeds.test @@ -579,7 +579,7 @@ class FeedsCSVtoUsersTest extends FeedsWebTestCase { // Assert result. $this->assertText('Created 4 users.'); // 1 user has an invalid email address. - $this->assertText('There were 1 users that could not be imported because either their name or their email was empty or not valid. Check import data and mapping settings on User processor.'); + $this->assertText('There was 1 user that could not be imported because either their name or their email was empty or not valid. Check import data and mapping settings on User processor.'); $this->drupalGet('admin/user/user'); $this->assertText('Morticia'); $this->assertText('Fester'); -- GitLab