[evolution-patches] Patch for handling plural forms (bug #53464)



Hi,
Not Zed instructed me to send patches here for quicker response.

I'm attaching one of the patches which partly resolves the following
bug:
  http://bugzilla.ximian.com/show_bug.cgi?id=53464

It's simple, but it touches a lot of code, so here're ChangeLog entries.

As mentioned in the bug report, it compiles cleanly, and at least
some of situations I was able to trigger caused no problems.

mail/ChangeLog:
	
2004-03-13  Danilo Šegan  <dsegan gmx net>

	* mail-ops.c (get_messages_desc): Use ngettext for handling
	plural-forms.
	(save_messages_desc): Likewise.

calendar/ChangeLog:
2004-03-13  Danilo Šegan  <dsegan gmx net>

	* gui/e-alarm-list.c (get_alarm_duration_string): Use ngettext for
	handling plural forms.

	* gui/e-itip-control.c (write_recurrence_piece): Likewise.

	* gui/dialogs/delete-comp.c (delete_component_dialog): Likewise.

addressbook/ChangeLog:
	
2004-03-13  Danilo Šegan  <dsegan gmx net>

	* gui/widgets/e-addressbook-model.c (update_folder_bar_message):
	Use ngettext for handling plural forms.

	* gui/widgets/eab-gui-util.c (eab_show_multiple_contacts): Likewise.

	* gui/widgets/eab-vcard-control.c (pstream_load): Likewise.

Index: addressbook/gui/widgets/e-addressbook-model.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-addressbook-model.c,v
retrieving revision 1.59
diff -u -r1.59 e-addressbook-model.c
--- addressbook/gui/widgets/e-addressbook-model.c	19 Feb 2004 21:40:21 -0000	1.59
+++ addressbook/gui/widgets/e-addressbook-model.c	11 Mar 2004 17:07:14 -0000
@@ -147,11 +147,8 @@
 	case 0:
 		message = g_strdup (_("No contacts"));
 		break;
-	case 1:
-		message = g_strdup (_("1 contact"));
-		break;
 	default:
-		message = g_strdup_printf (_("%d contacts"), count);
+		message = g_strdup_printf (ngettext("%d contact", "%d contacts", count), count);
 		break;
 	}
 
Index: addressbook/gui/widgets/eab-gui-util.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/eab-gui-util.c,v
retrieving revision 1.8
diff -u -r1.8 eab-gui-util.c
--- addressbook/gui/widgets/eab-gui-util.c	11 Feb 2004 20:29:33 -0000	1.8
+++ addressbook/gui/widgets/eab-gui-util.c	11 Mar 2004 17:07:19 -0000
@@ -204,8 +204,11 @@
 							 0,
 							 GTK_MESSAGE_QUESTION,
 							 GTK_BUTTONS_YES_NO,
-							 _("Opening %d contacts will open %d new windows as well.\n"
-							   "Do you really want to display all of these contacts?"),
+							 ngettext("Opening %d contact will open %d new window as well.\n"
+								  "Do you really want to display this contact?",
+								  "Opening %d contacts will open %d new windows as well.\n"
+								  "Do you really want to display all of these contacts?",
+								  length),
 							 length,
 							 length);
 
Index: addressbook/gui/widgets/eab-vcard-control.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/eab-vcard-control.c,v
retrieving revision 1.4
diff -u -r1.4 eab-vcard-control.c
--- addressbook/gui/widgets/eab-vcard-control.c	1 Dec 2003 22:14:17 -0000	1.4
+++ addressbook/gui/widgets/eab-vcard-control.c	11 Mar 2004 17:07:20 -0000
@@ -136,11 +136,9 @@
 	if (list && list->next) {
 		char *message;
 		int length = g_list_length (list) - 1;
-		if (length > 1) {
-			message = g_strdup_printf (_("and %d other contacts."), length);
-		} else {
-			message = g_strdup_printf (_("and one other contact."));
-		}
+		message = g_strdup_printf (ngettext("and one other contact.", 
+						    "and %d other contacts.", length), 
+					   length);
 		gtk_label_set_text (GTK_LABEL (vcard_control->label), message);
 		g_free (message);
 		gtk_widget_show (vcard_control->label);
Index: calendar/gui/e-alarm-list.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-alarm-list.c,v
retrieving revision 1.7
diff -u -r1.7 e-alarm-list.c
--- calendar/gui/e-alarm-list.c	6 Feb 2004 03:03:41 -0000	1.7
+++ calendar/gui/e-alarm-list.c	11 Mar 2004 17:07:25 -0000
@@ -391,43 +391,28 @@
 
 	have_something = FALSE;
 
-	if (duration->days > 1) {
-		g_string_sprintf (string, _("%d days"), duration->days);
-		have_something = TRUE;
-	} else if (duration->days == 1) {
-		g_string_append (string, _("1 day"));
+	if (duration->days >= 1) {
+		g_string_sprintf (string, ngettext("%d day", "%d days", duration->days), duration->days);
 		have_something = TRUE;
 	}
 
-	if (duration->weeks > 1) {
-		g_string_sprintf (string, _("%d weeks"), duration->weeks);
-		have_something = TRUE;
-	} else if (duration->weeks == 1) {
-		g_string_append (string, _("1 week"));
+	if (duration->weeks >= 1) {
+		g_string_sprintf (string, ngettext("%d week","%d weeks", duration->weeks), duration->weeks);
 		have_something = TRUE;
 	}
 
-	if (duration->hours > 1) {
-		g_string_sprintf (string, _("%d hours"), duration->hours);
-		have_something = TRUE;
-	} else if (duration->hours == 1) {
-		g_string_append (string, _("1 hour"));
+	if (duration->hours >= 1) {
+		g_string_sprintf (string, ngettext("%d hour", "%d hours", duration->hours), duration->hours);
 		have_something = TRUE;
 	}
 
-	if (duration->minutes > 1) {
-		g_string_sprintf (string, _("%d minutes"), duration->minutes);
-		have_something = TRUE;
-	} else if (duration->minutes == 1) {
-		g_string_append (string, _("1 minute"));
+	if (duration->minutes >= 1) {
+		g_string_sprintf (string, ngettext("%d minute", "%d minutes", duration->minutes), duration->minutes);
 		have_something = TRUE;
 	}
 
-	if (duration->seconds > 1) {
-		g_string_sprintf (string, _("%d seconds"), duration->seconds);
-		have_something = TRUE;
-	} else if (duration->seconds == 1) {
-		g_string_append (string, _("1 second"));
+	if (duration->seconds >= 1) {
+		g_string_sprintf (string, ngettext("%d second", "%d seconds", duration->seconds), duration->seconds);
 		have_something = TRUE;
 	}
 
Index: calendar/gui/e-itip-control.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-itip-control.c,v
retrieving revision 1.140
diff -u -r1.140 e-itip-control.c
--- calendar/gui/e-itip-control.c	6 Feb 2004 03:03:42 -0000	1.140
+++ calendar/gui/e-itip-control.c	11 Mar 2004 17:07:35 -0000
@@ -599,23 +599,14 @@
 
 	switch (r->freq) {
 	case ICAL_DAILY_RECURRENCE:
-		if (r->interval == 1)
-			strcpy (buffer, _("Every day"));
-		else
-			sprintf (buffer, _("Every %d days"), r->interval);
+		sprintf (buffer, ngettext("Every day", "Every %d days", r->interval), r->interval);
 		break;
 
 	case ICAL_WEEKLY_RECURRENCE:
 		if (r->by_day[0] == ICAL_RECURRENCE_ARRAY_MAX) {
-			if (r->interval == 1)
-				strcpy (buffer, _("Every week"));
-			else
-				sprintf (buffer, _("Every %d weeks"), r->interval);
+			sprintf (buffer, ngettext("Every week", "Every %d weeks", r->interval), r->interval);
 		} else {
-			if (r->interval == 1)
-				strcpy (buffer, _("Every week on "));
-			else
-				sprintf (buffer, _("Every %d weeks on "), r->interval);
+			sprintf (buffer, ngettext("Every week on ", "Every %d weeks on ", r->interval), r->interval);
 
 			for (i = 1; i < 8 && r->by_day[i] != ICAL_RECURRENCE_ARRAY_MAX; i++) {
 				if (i > 1)
@@ -647,22 +638,14 @@
 				 nth (pos), get_dayname (r, 0));
 		}
 
-		if (r->interval == 1)
-			strcat (buffer, _("every month"));
-		else {
-			len = strlen (buffer);
-			buffer += len;
-			size -= len;
-			sprintf (buffer, _("every %d months"), r->interval);
-		}
+		len = strlen (buffer);
+		buffer += len;
+		size -= len;
+		sprintf (buffer, ngettext("every month","every %d months", r->interval), r->interval);
 		break;
 
 	case ICAL_YEARLY_RECURRENCE:
-		if (r->interval == 1)
-			strcpy (buffer, _("Every year"));
-		else {
-			sprintf (buffer, _("Every %d years"), r->interval);
-		}
+		sprintf (buffer, ngettext("Every year", "Every %d years", r->interval), r->interval);
 		break;
 
 	default:
@@ -673,7 +656,7 @@
 	buffer += len;
 	size -= len;
 	if (r->count) {
-		sprintf (buffer, _(" a total of %d times"), r->count);
+		sprintf (buffer, ngettext("a total of %d time", " a total of %d times", r->count), r->count);
 	} else if (!icaltime_is_null_time (r->until)) {
 		ECalComponentDateTime dt;
 
Index: calendar/gui/dialogs/delete-comp.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/delete-comp.c,v
retrieving revision 1.22
diff -u -r1.22 delete-comp.c
--- calendar/gui/dialogs/delete-comp.c	12 Feb 2004 09:44:47 -0000	1.22
+++ calendar/gui/dialogs/delete-comp.c	11 Mar 2004 17:07:37 -0000
@@ -128,18 +128,24 @@
 	} else {
 		switch (vtype) {
 		case E_CAL_COMPONENT_EVENT:
-			str = g_strdup_printf (_("Are you sure you want to delete "
-						 "%d appointments?"), n_comps);
+			str = g_strdup_printf (ngettext("Are you sure you want to delete "
+							"%d appointment?",
+							"Are you sure you want to delete "
+							"%d appointments?", n_comps), n_comps);
 			break;
 
 		case E_CAL_COMPONENT_TODO:
-			str = g_strdup_printf (_("Are you sure you want to delete "
-						 "%d tasks?"), n_comps);
+			str = g_strdup_printf (ngettext("Are you sure you want to delete "
+							"%d task?",
+							"Are you sure you want to delete "
+							"%d tasks?", n_comps), n_comps);
 			break;
 
 		case E_CAL_COMPONENT_JOURNAL:
-			str = g_strdup_printf (_("Are you sure you want to delete "
-						 "%d journal entries?"), n_comps);
+			str = g_strdup_printf (ngettext("Are you sure you want to delete "
+							"%d journal entry?",
+							"Are you sure you want to delete "
+							"%d journal entries?", n_comps), n_comps);
 			break;
 
 		default:
Index: mail/mail-ops.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-ops.c,v
retrieving revision 1.421
diff -u -r1.421 mail-ops.c
--- mail/mail-ops.c	11 Mar 2004 03:05:43 -0000	1.421
+++ mail/mail-ops.c	11 Mar 2004 17:07:53 -0000
@@ -1882,7 +1882,9 @@
 {
 	struct _get_messages_msg *m = (struct _get_messages_msg *)mm;
 
-	return g_strdup_printf(_("Retrieving %d message(s)"), m->uids->len);
+	return g_strdup_printf(ngettext("Retrieving %d message",
+					"Retrieving %d messages", m->uids->len), 
+			       m->uids->len);
 }
 
 static void get_messages_get(struct _mail_msg *mm)
@@ -1966,7 +1968,9 @@
 {
 	struct _save_messages_msg *m = (struct _save_messages_msg *)mm;
 
-	return g_strdup_printf(_("Saving %d messsage(s)"), m->uids->len);
+	return g_strdup_printf(ngettext("Saving %d message", 
+					"Saving %d messsages", m->uids->len), 
+			       m->uids->len);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]