diff options
author | Danilo Šegan <danilo@src.gnome.org> | 2004-03-20 13:01:24 +0800 |
---|---|---|
committer | Danilo Šegan <danilo@src.gnome.org> | 2004-03-20 13:01:24 +0800 |
commit | d25eaf67599639c54a83f4341aca22ac531050b6 (patch) | |
tree | bf4096bb87df7017fdc752490d49e72c23769ef6 /filter/filter-datespec.c | |
parent | cce45ea42e294b90a1a5f8ac0a11f32872491d48 (diff) | |
download | gsoc2013-evolution-d25eaf67599639c54a83f4341aca22ac531050b6.tar.gz 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/filter-datespec.c')
-rw-r--r-- | filter/filter-datespec.c | 32 |
1 files changed, 19 insertions, 13 deletions
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; } |