aboutsummaryrefslogtreecommitdiffstats
path: root/filter
diff options
context:
space:
mode:
authorDanilo Šegan <danilo@src.gnome.org>2004-03-20 13:01:24 +0800
committerDanilo Šegan <danilo@src.gnome.org>2004-03-20 13:01:24 +0800
commitd25eaf67599639c54a83f4341aca22ac531050b6 (patch)
treebf4096bb87df7017fdc752490d49e72c23769ef6 /filter
parentcce45ea42e294b90a1a5f8ac0a11f32872491d48 (diff)
downloadgsoc2013-evolution-d25eaf67599639c54a83f4341aca22ac531050b6.tar
gsoc2013-evolution-d25eaf67599639c54a83f4341aca22ac531050b6.tar.gz
gsoc2013-evolution-d25eaf67599639c54a83f4341aca22ac531050b6.tar.bz2
gsoc2013-evolution-d25eaf67599639c54a83f4341aca22ac531050b6.tar.lz
gsoc2013-evolution-d25eaf67599639c54a83f4341aca22ac531050b6.tar.xz
gsoc2013-evolution-d25eaf67599639c54a83f4341aca22ac531050b6.tar.zst
gsoc2013-evolution-d25eaf67599639c54a83f4341aca22ac531050b6.zip
Use ngettext for handling plurals in filter-datespec. Partial fix for #53464).
svn path=/trunk/; revision=25135
Diffstat (limited to 'filter')
-rw-r--r--filter/ChangeLog6
-rw-r--r--filter/filter-datespec.c32
2 files changed, 25 insertions, 13 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index b3eb1398c4..67c256df5d 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,9 @@
+2004-03-20 Danilo Šegan <dsegan@gmx.net>
+
+ * filter-datespec.c (set_button): Use ngettext for handling plurals.
+ (timespans): Use C preprocessor hacks to make xgettext see real
+ ngettext messages (fixes part of #53464).
+
2004-03-16 Jeffrey Stedfast <fejj@ximian.com>
* filter-rule.c (rule_copy): Don't ref the newly cloned rule (fix
diff --git a/filter/filter-datespec.c b/filter/filter-datespec.c
index 2c8ddb4a90..f913b20ed8 100644
--- a/filter/filter-datespec.c
+++ b/filter/filter-datespec.c
@@ -61,16 +61,27 @@ typedef struct _timespan {
float max;
} timespan;
+#ifdef ngettext
+#undef ngettext
+#endif
+
+/* This is a nasty hack trying to keep both ngettext function and xgettext tool happy */
+/* It *will* cause problems if ngettext is a macro */
+#define ngettext(a, b) a, b
+
static const timespan timespans[] = {
- { 1, N_("1 second ago"), N_("%d seconds ago"), 59.0 },
- { 60, N_("1 minute ago"), N_("%d minutes ago"), 59.0 },
- { 3600, N_("1 hour ago"), N_("%d hours ago"), 23.0 },
- { 86400, N_("1 day ago"), N_("%d days ago"), 31.0 },
- { 604800, N_("1 week ago"), N_("%d weeks ago"), 52.0 },
- { 2419200, N_("1 month ago"), N_("%d months ago"), 12.0 },
- { 31557600, N_("1 year ago"), N_("%d years ago"), 1000.0 },
+ { 1, ngettext("1 second ago", "%d seconds ago"), 59.0 },
+ { 60, ngettext("1 minute ago", "%d minutes ago"), 59.0 },
+ { 3600, ngettext("1 hour ago", "%d hours ago"), 23.0 },
+ { 86400, ngettext("1 day ago", "%d days ago"), 31.0 },
+ { 604800, ngettext("1 week ago", "%d weeks ago"), 52.0 },
+ { 2419200, ngettext("1 month ago", "%d months ago"), 12.0 },
+ { 31557600, ngettext("1 year ago", "%d years ago"), 1000.0 },
};
+/* now we let the compiler see the real function call */
+#undef ngettext
+
#define DAY_INDEX 3
#define N_TIMESPANS (sizeof (timespans) / sizeof (timespans[0]))
@@ -294,12 +305,7 @@ set_button (FilterDatespec *fds)
span = get_best_span(fds->value);
count = fds->value / timespans[span].seconds;
- if (count == 1)
- /* 1 (minute|day|...) ago (singular time ago) */
- strcpy(buf, _(timespans[span].singular));
- else
- /* N (minutes|days|...) ago (plural time ago) */
- sprintf(buf, _(timespans[span].plural), count);
+ sprintf(buf, ngettext(timespans[span].singular, timespans[span].plural, count), count);
}
break;
}