From d37b47088f5a3420823da99e3574890be8c14014 Mon Sep 17 00:00:00 2001 From: Reis Radomil Date: Sun, 22 Apr 2018 04:15:57 +0000 Subject: [PATCH] I18N: Use ngettext to choose correct plural form Avoid the antipattern printf(n == 1 ? _("one thing") : _("%d things"), n); instead use printf(ngettext("one thing", "%d things", n), n); (note: n has to be passed to ngettext and printf) Although most Germanic languages (including English) use the singular form for n=1 and a (single) plural form for all other n (including n=0), this is not the case in general. An example from the GNU gettext manual [0] for Polish work plik (file): 1 plik 2,3,4 pliki 5-21 pliko'w 22-24 pliki 25-31 pliko'w When using numbers in translatable strings, do not choose the translated plural form in the code. Instead let GNU gettext capability pick the correct translated plural (provided by a translator) depending on the number. [0] https://www.gnu.org/software/gettext/manual/html_chapter/gettext.html#Plural-forms --- mx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mx.c b/mx.c index 79b0cf0c9..0b9c0375b 100644 --- a/mx.c +++ b/mx.c @@ -768,7 +768,7 @@ int mx_close_mailbox(struct Context *ctx, int *index_hint) if (ctx->deleted && !(ctx->magic == MUTT_MAILDIR && MaildirTrash)) { snprintf(buf, sizeof(buf), - ctx->deleted == 1 ? _("Purge %d deleted message?") : _("Purge %d deleted messages?"), + ngettext("Purge %d deleted message?", "Purge %d deleted messages?", ctx->deleted), ctx->deleted); purge = query_quadoption(Delete, buf); if (purge == MUTT_ABORT) @@ -1074,7 +1074,7 @@ int mx_sync_mailbox(struct Context *ctx, int *index_hint) char buf[SHORT_STRING]; snprintf(buf, sizeof(buf), - ctx->deleted == 1 ? _("Purge %d deleted message?") : _("Purge %d deleted messages?"), + ngettext("Purge %d deleted message?", "Purge %d deleted messages?", ctx->deleted), ctx->deleted); purge = query_quadoption(Delete, buf); if (purge == MUTT_ABORT) -- 2.40.0