From f54381583da51b0ffd93f4afc9c71d6920482366 Mon Sep 17 00:00:00 2001 From: Reis Radomil Date: Sun, 22 Apr 2018 04:15:58 +0000 Subject: [PATCH] I18N: Use ngettext to select plural form for a string Convert some occurrences of printf("%d things", n); to printf(ngettext("%d thing", "%d things", n), n); --- compose.c | 3 ++- curs_main.c | 2 +- imap/imap.c | 9 +++++++-- imap/message.c | 3 ++- pager.c | 2 +- pop.c | 11 +++++++++-- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/compose.c b/compose.c index 12d809a4c..c7869dbd0 100644 --- a/compose.c +++ b/compose.c @@ -1037,7 +1037,8 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen, int error = 0; if (numfiles > 1) - mutt_message(_("Attaching selected files...")); + mutt_message(ngettext("Attaching selected file...", + "Attaching selected files...", numfiles)); for (i = 0; i < numfiles; i++) { char *att = files[i]; diff --git a/curs_main.c b/curs_main.c index 5f1641529..78e3e2c21 100644 --- a/curs_main.c +++ b/curs_main.c @@ -2915,7 +2915,7 @@ int mutt_index_menu(void) menu->redraw = REDRAW_FULL; /* L10N: This is displayed when the x-label on one or more * messages is edited. */ - mutt_message(_("%d labels changed."), rc); + mutt_message(ngettext("%d label changed.", "%d labels changed.", rc), rc); } else { diff --git a/imap/imap.c b/imap/imap.c index efa771c8c..c685c55c0 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -2403,7 +2403,9 @@ int imap_sync_mailbox(struct Context *ctx, int expunge) for (int i = 0; i < ctx->msgcount; i++) if (ctx->hdrs[i]->deleted && ctx->hdrs[i]->changed) ctx->hdrs[i]->active = false; - mutt_message(_("Marking %d messages deleted..."), rc); + mutt_message(ngettext("Marking %d message deleted...", + "Marking %d messages deleted...", rc), + rc); } } @@ -2435,7 +2437,10 @@ int imap_sync_mailbox(struct Context *ctx, int expunge) if ((h->env && (h->env->refs_changed || h->env->irt_changed)) || h->attach_del || h->xlabel_changed) { - mutt_message(_("Saving changed messages... [%d/%d]"), i + 1, ctx->msgcount); + /* L10N: The plural is choosen by the last %d, i.e. the total number */ + mutt_message(ngettext("Saving changed message... [%d/%d]", + "Saving changed messages... [%d/%d]", ctx->msgcount), + i + 1, ctx->msgcount); if (!appendctx) appendctx = mx_open_mailbox(ctx->path, MUTT_APPEND | MUTT_QUIET, NULL); if (!appendctx) diff --git a/imap/message.c b/imap/message.c index 220c8d78d..ce82b4015 100644 --- a/imap/message.c +++ b/imap/message.c @@ -1449,7 +1449,8 @@ int imap_copy_messages(struct Context *ctx, struct Header *h, char *dest, int de goto out; } else - mutt_message(_("Copying %d messages to %s..."), rc, mbox); + mutt_message(ngettext("Copying %d message to %s...", "Copying %d messages to %s...", rc), + rc, mbox); } else { diff --git a/pager.c b/pager.c index c9741a1b6..7d27fbfbf 100644 --- a/pager.c +++ b/pager.c @@ -3197,7 +3197,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e { Context->changed = true; pager_menu->redraw = REDRAW_FULL; - mutt_message(_("%d labels changed."), rc); + mutt_message(ngettext("%d label changed.", "%d labels changed.", rc), rc); } else { diff --git a/pop.c b/pop.c index db48b2e05..a454883e7 100644 --- a/pop.c +++ b/pop.c @@ -343,7 +343,10 @@ static int pop_fetch_headers(struct Context *ctx) } if (deleted > 0) { - mutt_error(_("%d messages have been lost. Try reopening the mailbox."), deleted); + mutt_error( + ngettext("%d message has been lost. Try reopening the mailbox.", + "%d messages have been lost. Try reopening the mailbox.", deleted), + deleted); } bool hcached = false; @@ -995,7 +998,11 @@ void pop_fetch_mail(void) break; } - mutt_message(_("%s [%d of %d messages read]"), msgbuf, i - last, msgs - last); + /* L10N: The plural is picked by the second numerical argument, i.e. + * the %d right before 'messages', i.e. the total number of messages. */ + mutt_message(ngettext("%s [%d of %d message read]", + "%s [%d of %d messages read]", msgs - last), + msgbuf, i - last, msgs - last); } mx_close_mailbox(&ctx, NULL); -- 2.40.0