]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.1.0306: plural messages are not translated properly v8.1.0306
authorBram Moolenaar <Bram@vim.org>
Tue, 21 Aug 2018 13:12:14 +0000 (15:12 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 21 Aug 2018 13:12:14 +0000 (15:12 +0200)
Problem:    Plural messages are not translated properly.
Solution:   Add more usage of NGETTEXT(). (Sergey Alyoshin)

src/buffer.c
src/ex_cmds.c
src/ex_docmd.c
src/fileio.c
src/misc1.c
src/ops.c
src/version.c
src/vim.h

index 64053725468b66950cc874718e75b1b8e94442c6..6bcd28b36c1283c09df993499dc64eb074c923d6 100644 (file)
@@ -1174,26 +1174,14 @@ do_bufdel(
        else if (deleted >= p_report)
        {
            if (command == DOBUF_UNLOAD)
-           {
-               if (deleted == 1)
-                   MSG(_("1 buffer unloaded"));
-               else
-                   smsg((char_u *)_("%d buffers unloaded"), deleted);
-           }
+               smsg((char_u *)NGETTEXT("%d buffer unloaded",
+                           "%d buffers unloaded", deleted), deleted);
            else if (command == DOBUF_DEL)
-           {
-               if (deleted == 1)
-                   MSG(_("1 buffer deleted"));
-               else
-                   smsg((char_u *)_("%d buffers deleted"), deleted);
-           }
+               smsg((char_u *)NGETTEXT("%d buffer deleted",
+                           "%d buffers deleted", deleted), deleted);
            else
-           {
-               if (deleted == 1)
-                   MSG(_("1 buffer wiped out"));
-               else
-                   smsg((char_u *)_("%d buffers wiped out"), deleted);
-           }
+               smsg((char_u *)NGETTEXT("%d buffer wiped out",
+                           "%d buffers wiped out", deleted), deleted);
        }
     }
 
@@ -3485,19 +3473,14 @@ fileinfo(
        n = (int)(((long)curwin->w_cursor.lnum * 100L) /
                                            (long)curbuf->b_ml.ml_line_count);
     if (curbuf->b_ml.ml_flags & ML_EMPTY)
-    {
        vim_snprintf_add((char *)buffer, IOSIZE, "%s", _(no_lines_msg));
-    }
 #ifdef FEAT_CMDL_INFO
     else if (p_ru)
-    {
        /* Current line and column are already on the screen -- webb */
-       if (curbuf->b_ml.ml_line_count == 1)
-           vim_snprintf_add((char *)buffer, IOSIZE, _("1 line --%d%%--"), n);
-       else
-           vim_snprintf_add((char *)buffer, IOSIZE, _("%ld lines --%d%%--"),
-                                        (long)curbuf->b_ml.ml_line_count, n);
-    }
+       vim_snprintf_add((char *)buffer, IOSIZE,
+               NGETTEXT("%ld line --%d%%--", "%ld lines --%d%%--",
+                                                  curbuf->b_ml.ml_line_count),
+               (long)curbuf->b_ml.ml_line_count, n);
 #endif
     else
     {
index bee50c5955f2f23c06d6dde6ed513250d45affba..6e713c49a38eaaad55bdfcf85b2817bc36bbda91 100644 (file)
@@ -985,12 +985,8 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
        ml_delete(line1 + extra, TRUE);
 
     if (!global_busy && num_lines > p_report)
-    {
-       if (num_lines == 1)
-           MSG(_("1 line moved"));
-       else
-           smsg((char_u *)_("%ld lines moved"), num_lines);
-    }
+       smsg((char_u *)NGETTEXT("%ld line moved", "%ld lines moved", num_lines),
+                       (long)num_lines);
 
     /*
      * Leave the cursor on the last of the moved lines.
@@ -5940,23 +5936,29 @@ do_sub_msg(
                || count_only)
            && messaging())
     {
+       char    *msg_single;
+       char    *msg_plural;
+
        if (got_int)
            STRCPY(msg_buf, _("(Interrupted) "));
        else
            *msg_buf = NUL;
-       if (sub_nsubs == 1)
-           vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
-                   "%s", count_only ? _("1 match") : _("1 substitution"));
-       else
-           vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
-                   count_only ? _("%ld matches") : _("%ld substitutions"),
-                                                                  sub_nsubs);
-       if (sub_nlines == 1)
-           vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
-                   "%s", _(" on 1 line"));
-       else
-           vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
-                   _(" on %ld lines"), (long)sub_nlines);
+
+       msg_single = count_only
+                   ? NGETTEXT("%ld match on %ld line",
+                                         "%ld matches on %ld line", sub_nsubs)
+                   : NGETTEXT("%ld substitution on %ld line",
+                                  "%ld substitutions on %ld line", sub_nsubs);
+       msg_plural = count_only
+                   ? NGETTEXT("%ld match on %ld lines",
+                                        "%ld matches on %ld lines", sub_nsubs)
+                   : NGETTEXT("%ld substitution on %ld lines",
+                                 "%ld substitutions on %ld lines", sub_nsubs);
+
+       vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
+                                NGETTEXT(msg_single, msg_plural, sub_nlines),
+                                sub_nsubs, (long)sub_nlines);
+
        if (msg(msg_buf))
            /* save message to display it after redraw */
            set_keep_msg(msg_buf, 0);
index 14ec213239245d5d63225e07e1add6278aa1492e..ccd96b1d326e1b574b8f28ce03671ac4bad3a54b 100644 (file)
@@ -5749,22 +5749,16 @@ check_more(
            {
                char_u  buff[DIALOG_MSG_SIZE];
 
-               if (n == 1)
-                   vim_strncpy(buff,
-                           (char_u *)_("1 more file to edit.  Quit anyway?"),
-                                                        DIALOG_MSG_SIZE - 1);
-               else
-                   vim_snprintf((char *)buff, DIALOG_MSG_SIZE,
-                             _("%d more files to edit.  Quit anyway?"), n);
+               vim_snprintf((char *)buff, DIALOG_MSG_SIZE,
+                       NGETTEXT("%d more file to edit.  Quit anyway?",
+                           "%d more files to edit.  Quit anyway?", n), n);
                if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES)
                    return OK;
                return FAIL;
            }
 #endif
-           if (n == 1)
-               EMSG(_("E173: 1 more file to edit"));
-           else
-               EMSGN(_("E173: %ld more files to edit"), n);
+           EMSGN(NGETTEXT("E173: %ld more file to edit",
+                       "E173: %ld more files to edit", n), n);
            quitmore = 2;           /* next try to quit is allowed */
        }
        return FAIL;
index 7bceb75fd71facd14856f1d806fdff6230be8ed9..d00dc5e47ba43ce5ff34cd0c6516d13f0b014c60 100644 (file)
@@ -5349,16 +5349,11 @@ msg_add_lines(
                "%ldL, %lldC", lnum, (long long)nchars);
     else
     {
-       if (lnum == 1)
-           STRCPY(p, _("1 line, "));
-       else
-           sprintf((char *)p, _("%ld lines, "), lnum);
+       sprintf((char *)p, NGETTEXT("%ld line, ", "%ld lines, ", lnum), lnum);
        p += STRLEN(p);
-       if (nchars == 1)
-           STRCPY(p, _("1 character"));
-       else
-           vim_snprintf((char *)p, IOSIZE - (p - IObuff),
-                   _("%lld characters"), (long long)nchars);
+       vim_snprintf((char *)p, IOSIZE - (p - IObuff),
+               NGETTEXT("%lld character", "%lld characters", nchars),
+               (long long)nchars);
     }
 }
 
index 1647aa952413b95109648cb248bb902c463dca7b..f2aa96b372b2e4121b7d2c14d650b85d93dea864 100644 (file)
@@ -3802,24 +3802,12 @@ msgmore(long n)
 
     if (pn > p_report)
     {
-       if (pn == 1)
-       {
-           if (n > 0)
-               vim_strncpy(msg_buf, (char_u *)_("1 more line"),
-                                                            MSG_BUF_LEN - 1);
-           else
-               vim_strncpy(msg_buf, (char_u *)_("1 line less"),
-                                                            MSG_BUF_LEN - 1);
-       }
+       if (n > 0)
+           vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
+                   NGETTEXT("%ld more line", "%ld more lines", pn), pn);
        else
-       {
-           if (n > 0)
-               vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
-                                                    _("%ld more lines"), pn);
-           else
-               vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
-                                                   _("%ld fewer lines"), pn);
-       }
+           vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
+                   NGETTEXT("%ld line less", "%ld fewer lines", pn), pn);
        if (got_int)
            vim_strcat(msg_buf, (char_u *)_(" (Interrupted)"), MSG_BUF_LEN);
        if (msg(msg_buf))
index 50ebf444953f04a009451b6869a9d2e668da1101..3384556f90540a8821e237a884b577a2542e45ae 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -244,7 +244,6 @@ op_shift(oparg_T *oap, int curs_top, int amount)
 {
     long           i;
     int                    first_char;
-    char_u         *s;
     int                    block_col = 0;
 
     if (u_save((linenr_T)(oap->start.lnum - 1),
@@ -297,26 +296,21 @@ op_shift(oparg_T *oap, int curs_top, int amount)
 
     if (oap->line_count > p_report)
     {
+       char        *op;
+       char        *msg_line_single;
+       char        *msg_line_plural;
+
        if (oap->op_type == OP_RSHIFT)
-           s = (char_u *)">";
-       else
-           s = (char_u *)"<";
-       if (oap->line_count == 1)
-       {
-           if (amount == 1)
-               sprintf((char *)IObuff, _("1 line %sed 1 time"), s);
-           else
-               sprintf((char *)IObuff, _("1 line %sed %d times"), s, amount);
-       }
+           op = ">";
        else
-       {
-           if (amount == 1)
-               sprintf((char *)IObuff, _("%ld lines %sed 1 time"),
-                                                         oap->line_count, s);
-           else
-               sprintf((char *)IObuff, _("%ld lines %sed %d times"),
-                                                 oap->line_count, s, amount);
-       }
+           op = "<";
+       msg_line_single = NGETTEXT("%ld line %sed %d time",
+                                            "%ld line %sed %d times", amount);
+       msg_line_plural = NGETTEXT("%ld lines %sed %d time",
+                                           "%ld lines %sed %d times", amount);
+       vim_snprintf((char *)IObuff, IOSIZE,
+               NGETTEXT(msg_line_single, msg_line_plural, oap->line_count),
+               oap->line_count, op, amount);
        msg(IObuff);
     }
 
@@ -789,10 +783,8 @@ op_reindent(oparg_T *oap, int (*how)(void))
     if (oap->line_count > p_report)
     {
        i = oap->line_count - (i + 1);
-       if (i == 1)
-           MSG(_("1 line indented "));
-       else
-           smsg((char_u *)_("%ld lines indented "), i);
+       smsg((char_u *)NGETTEXT("%ld line indented ",
+                                                "%ld lines indented ", i), i);
     }
     /* set '[ and '] marks */
     curbuf->b_op_start = oap->start;
@@ -2529,12 +2521,8 @@ op_tilde(oparg_T *oap)
     curbuf->b_op_end = oap->end;
 
     if (oap->line_count > p_report)
-    {
-       if (oap->line_count == 1)
-           MSG(_("1 line changed"));
-       else
-           smsg((char_u *)_("%ld lines changed"), oap->line_count);
-    }
+       smsg((char_u *)NGETTEXT("%ld line changed", "%ld lines changed",
+                                           oap->line_count), oap->line_count);
 }
 
 /*
@@ -3348,19 +3336,18 @@ op_yank(oparg_T *oap, int deleting, int mess)
 
            /* redisplay now, so message is not deleted */
            update_topline_redraw();
-           if (yanklines == 1)
+           if (oap->block_mode)
            {
-               if (oap->block_mode)
-                   smsg((char_u *)_("block of 1 line yanked%s"), namebuf);
-               else
-                   smsg((char_u *)_("1 line yanked%s"), namebuf);
+               smsg((char_u *)NGETTEXT("block of %ld line yanked%s",
+                                    "block of %ld lines yanked%s", yanklines),
+                       yanklines, namebuf);
            }
-           else if (oap->block_mode)
-               smsg((char_u *)_("block of %ld lines yanked%s"),
-                    yanklines, namebuf);
            else
-               smsg((char_u *)_("%ld lines yanked%s"), yanklines,
-                    namebuf);
+           {
+               smsg((char_u *)NGETTEXT("%ld line yanked%s",
+                                             "%ld lines yanked%s", yanklines),
+                       yanklines, namebuf);
+           }
        }
     }
 
@@ -5653,12 +5640,8 @@ op_addsub(
            curbuf->b_op_start = startpos;
 
        if (change_cnt > p_report)
-       {
-           if (change_cnt == 1)
-               MSG(_("1 line changed"));
-           else
-               smsg((char_u *)_("%ld lines changed"), change_cnt);
-       }
+           smsg((char_u *)NGETTEXT("%ld line changed", "%ld lines changed",
+                                                     change_cnt), change_cnt);
     }
 }
 
index 9cb104134c805c546c1e23896477c84636fb3396..5f03975c94f7199d7d9a5c49425d227011167e54 100644 (file)
@@ -794,6 +794,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    306,
 /**/
     305,
 /**/
index 794d2cd7738e393133153042b03800921300fe6d..ece5414fead41bf044116bdaf4cfb2885f10a4aa 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -553,6 +553,10 @@ extern int (*dyn_libintl_putenv)(const char *envstring);
 /*
  * The _() stuff is for using gettext().  It is a no-op when libintl.h is not
  * found or the +multilang feature is disabled.
+ * Use NGETTEXT(single, multi, number) to get plural behavior:
+ * - single - message for singular form
+ * - multi  - message for plural form
+ * - number - the count
  */
 #ifdef FEAT_GETTEXT
 # ifdef DYNAMIC_GETTEXT