]> granicus.if.org Git - neomutt/commitdiff
I18N: Choose correct plural form and avoid gluing translations
authorReis Radomil <reisradomil@fake-box.com>
Sun, 22 Apr 2018 04:16:00 +0000 (04:16 +0000)
committerRichard Russon <rich@flatcap.org>
Tue, 24 Apr 2018 20:29:44 +0000 (21:29 +0100)
Split up the horrible construction of choosing the plural and gluing
translations together. This should make the job of a translator easier.

Gluing translations is

   printf(_("Decode-save%s to mailbox"), h ? _("") : _(" tagged"));

instead of the better

   if (h)
     printf(_("Decode-save to mailbox"));
   else
     printf(_("Decode-save tagged to mailbox"));

commands.c

index 90a433824397829798930529a2f96f781ff0074e..a6c0bde15b1cc98ef80a6a4f77eda9ee742f2e71 100644 (file)
@@ -777,16 +777,42 @@ int mutt_save_message_ctx(struct Header *h, int delete, int decode, int decrypt,
 int mutt_save_message(struct Header *h, int delete, int decode, int decrypt)
 {
   int need_passphrase = 0, app = 0;
-  char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX];
+  char buf[_POSIX_PATH_MAX];
+  const char *prompt = NULL;
   struct Context ctx;
   struct stat st;
+  int msgcount; // for L10N with ngettext
 
-  snprintf(prompt, sizeof(prompt),
-           decode ?
-               (delete ? _("Decode-save%s to mailbox") : _("Decode-copy%s to mailbox")) :
-               (decrypt ? (delete ? _("Decrypt-save%s to mailbox") : _("Decrypt-copy%s to mailbox")) :
-                          (delete ? _("Save%s to mailbox") : _("Copy%s to mailbox"))),
-           h ? "" : _(" tagged"));
+  if (h)
+    msgcount = 1;
+  else if (Context)
+  {
+    msgcount = 0; // count the precise number of messages.
+    for (int i = 0; i < Context->msgcount; i++)
+      if (message_is_tagged(Context, i))
+        msgcount++;
+  }
+  else
+    msgcount = 0;
+
+  if (delete)
+  {
+    if (decode)
+      prompt = ngettext("Decode-save to mailbox", "Decode-save tagged to mailbox", msgcount);
+    else if (decrypt)
+      prompt = ngettext("Decrypt-save to mailbox", "Decrypt-save tagged to mailbox", msgcount);
+    else
+      prompt = ngettext("Save to mailbox", "Save tagged to mailbox", msgcount);
+  }
+  else
+  {
+    if (decode)
+      prompt = ngettext("Decode-copy to mailbox", "Decode-copy tagged to mailbox", msgcount);
+    else if (decrypt)
+      prompt = ngettext("Decrypt-copy to mailbox", "Decrypt-copy tagged to mailbox", msgcount);
+    else
+      prompt = ngettext("Copy to mailbox", "Copy tagged to mailbox", msgcount);
+  }
 
   if (h)
   {