patch 8.1.0306: plural messages are not translated properly

Problem:    Plural messages are not translated properly.
Solution:   Add more usage of NGETTEXT(). (Sergey Alyoshin)
This commit is contained in:
Bram Moolenaar
2018-08-21 15:12:14 +02:00
parent 830e3583da
commit da6e8919e7
8 changed files with 79 additions and 128 deletions

View File

@@ -1174,26 +1174,14 @@ do_bufdel(
else if (deleted >= p_report) else if (deleted >= p_report)
{ {
if (command == DOBUF_UNLOAD) if (command == DOBUF_UNLOAD)
{ smsg((char_u *)NGETTEXT("%d buffer unloaded",
if (deleted == 1) "%d buffers unloaded", deleted), deleted);
MSG(_("1 buffer unloaded"));
else
smsg((char_u *)_("%d buffers unloaded"), deleted);
}
else if (command == DOBUF_DEL) else if (command == DOBUF_DEL)
{ smsg((char_u *)NGETTEXT("%d buffer deleted",
if (deleted == 1) "%d buffers deleted", deleted), deleted);
MSG(_("1 buffer deleted"));
else else
smsg((char_u *)_("%d buffers deleted"), deleted); smsg((char_u *)NGETTEXT("%d buffer wiped out",
} "%d buffers wiped out", deleted), deleted);
else
{
if (deleted == 1)
MSG(_("1 buffer wiped out"));
else
smsg((char_u *)_("%d buffers wiped out"), deleted);
}
} }
} }
@@ -3485,19 +3473,14 @@ fileinfo(
n = (int)(((long)curwin->w_cursor.lnum * 100L) / n = (int)(((long)curwin->w_cursor.lnum * 100L) /
(long)curbuf->b_ml.ml_line_count); (long)curbuf->b_ml.ml_line_count);
if (curbuf->b_ml.ml_flags & ML_EMPTY) if (curbuf->b_ml.ml_flags & ML_EMPTY)
{
vim_snprintf_add((char *)buffer, IOSIZE, "%s", _(no_lines_msg)); vim_snprintf_add((char *)buffer, IOSIZE, "%s", _(no_lines_msg));
}
#ifdef FEAT_CMDL_INFO #ifdef FEAT_CMDL_INFO
else if (p_ru) else if (p_ru)
{
/* Current line and column are already on the screen -- webb */ /* Current line and column are already on the screen -- webb */
if (curbuf->b_ml.ml_line_count == 1) vim_snprintf_add((char *)buffer, IOSIZE,
vim_snprintf_add((char *)buffer, IOSIZE, _("1 line --%d%%--"), n); NGETTEXT("%ld line --%d%%--", "%ld lines --%d%%--",
else curbuf->b_ml.ml_line_count),
vim_snprintf_add((char *)buffer, IOSIZE, _("%ld lines --%d%%--"),
(long)curbuf->b_ml.ml_line_count, n); (long)curbuf->b_ml.ml_line_count, n);
}
#endif #endif
else else
{ {

View File

@@ -985,12 +985,8 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
ml_delete(line1 + extra, TRUE); ml_delete(line1 + extra, TRUE);
if (!global_busy && num_lines > p_report) if (!global_busy && num_lines > p_report)
{ smsg((char_u *)NGETTEXT("%ld line moved", "%ld lines moved", num_lines),
if (num_lines == 1) (long)num_lines);
MSG(_("1 line moved"));
else
smsg((char_u *)_("%ld lines moved"), num_lines);
}
/* /*
* Leave the cursor on the last of the moved lines. * Leave the cursor on the last of the moved lines.
@@ -5940,23 +5936,29 @@ do_sub_msg(
|| count_only) || count_only)
&& messaging()) && messaging())
{ {
char *msg_single;
char *msg_plural;
if (got_int) if (got_int)
STRCPY(msg_buf, _("(Interrupted) ")); STRCPY(msg_buf, _("(Interrupted) "));
else else
*msg_buf = NUL; *msg_buf = NUL;
if (sub_nsubs == 1)
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), vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
"%s", count_only ? _("1 match") : _("1 substitution")); NGETTEXT(msg_single, msg_plural, sub_nlines),
else sub_nsubs, (long)sub_nlines);
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);
if (msg(msg_buf)) if (msg(msg_buf))
/* save message to display it after redraw */ /* save message to display it after redraw */
set_keep_msg(msg_buf, 0); set_keep_msg(msg_buf, 0);

View File

@@ -5749,22 +5749,16 @@ check_more(
{ {
char_u buff[DIALOG_MSG_SIZE]; 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, vim_snprintf((char *)buff, DIALOG_MSG_SIZE,
_("%d more files to edit. Quit anyway?"), n); 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) if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES)
return OK; return OK;
return FAIL; return FAIL;
} }
#endif #endif
if (n == 1) EMSGN(NGETTEXT("E173: %ld more file to edit",
EMSG(_("E173: 1 more file to edit")); "E173: %ld more files to edit", n), n);
else
EMSGN(_("E173: %ld more files to edit"), n);
quitmore = 2; /* next try to quit is allowed */ quitmore = 2; /* next try to quit is allowed */
} }
return FAIL; return FAIL;

View File

@@ -5349,16 +5349,11 @@ msg_add_lines(
"%ldL, %lldC", lnum, (long long)nchars); "%ldL, %lldC", lnum, (long long)nchars);
else else
{ {
if (lnum == 1) sprintf((char *)p, NGETTEXT("%ld line, ", "%ld lines, ", lnum), lnum);
STRCPY(p, _("1 line, "));
else
sprintf((char *)p, _("%ld lines, "), lnum);
p += STRLEN(p); p += STRLEN(p);
if (nchars == 1)
STRCPY(p, _("1 character"));
else
vim_snprintf((char *)p, IOSIZE - (p - IObuff), vim_snprintf((char *)p, IOSIZE - (p - IObuff),
_("%lld characters"), (long long)nchars); NGETTEXT("%lld character", "%lld characters", nchars),
(long long)nchars);
} }
} }

View File

@@ -3801,25 +3801,13 @@ msgmore(long n)
pn = -n; pn = -n;
if (pn > p_report) 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);
}
else
{ {
if (n > 0) if (n > 0)
vim_snprintf((char *)msg_buf, MSG_BUF_LEN, vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
_("%ld more lines"), pn); NGETTEXT("%ld more line", "%ld more lines", pn), pn);
else else
vim_snprintf((char *)msg_buf, MSG_BUF_LEN, vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
_("%ld fewer lines"), pn); NGETTEXT("%ld line less", "%ld fewer lines", pn), pn);
}
if (got_int) if (got_int)
vim_strcat(msg_buf, (char_u *)_(" (Interrupted)"), MSG_BUF_LEN); vim_strcat(msg_buf, (char_u *)_(" (Interrupted)"), MSG_BUF_LEN);
if (msg(msg_buf)) if (msg(msg_buf))

View File

@@ -244,7 +244,6 @@ op_shift(oparg_T *oap, int curs_top, int amount)
{ {
long i; long i;
int first_char; int first_char;
char_u *s;
int block_col = 0; int block_col = 0;
if (u_save((linenr_T)(oap->start.lnum - 1), 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) if (oap->line_count > p_report)
{ {
char *op;
char *msg_line_single;
char *msg_line_plural;
if (oap->op_type == OP_RSHIFT) if (oap->op_type == OP_RSHIFT)
s = (char_u *)">"; op = ">";
else else
s = (char_u *)"<"; op = "<";
if (oap->line_count == 1) msg_line_single = NGETTEXT("%ld line %sed %d time",
{ "%ld line %sed %d times", amount);
if (amount == 1) msg_line_plural = NGETTEXT("%ld lines %sed %d time",
sprintf((char *)IObuff, _("1 line %sed 1 time"), s); "%ld lines %sed %d times", amount);
else vim_snprintf((char *)IObuff, IOSIZE,
sprintf((char *)IObuff, _("1 line %sed %d times"), s, amount); NGETTEXT(msg_line_single, msg_line_plural, oap->line_count),
} oap->line_count, op, amount);
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);
}
msg(IObuff); msg(IObuff);
} }
@@ -789,10 +783,8 @@ op_reindent(oparg_T *oap, int (*how)(void))
if (oap->line_count > p_report) if (oap->line_count > p_report)
{ {
i = oap->line_count - (i + 1); i = oap->line_count - (i + 1);
if (i == 1) smsg((char_u *)NGETTEXT("%ld line indented ",
MSG(_("1 line indented ")); "%ld lines indented ", i), i);
else
smsg((char_u *)_("%ld lines indented "), i);
} }
/* set '[ and '] marks */ /* set '[ and '] marks */
curbuf->b_op_start = oap->start; curbuf->b_op_start = oap->start;
@@ -2529,12 +2521,8 @@ op_tilde(oparg_T *oap)
curbuf->b_op_end = oap->end; curbuf->b_op_end = oap->end;
if (oap->line_count > p_report) if (oap->line_count > p_report)
{ smsg((char_u *)NGETTEXT("%ld line changed", "%ld lines changed",
if (oap->line_count == 1) oap->line_count), oap->line_count);
MSG(_("1 line changed"));
else
smsg((char_u *)_("%ld lines changed"), oap->line_count);
}
} }
/* /*
@@ -3348,19 +3336,18 @@ op_yank(oparg_T *oap, int deleting, int mess)
/* redisplay now, so message is not deleted */ /* redisplay now, so message is not deleted */
update_topline_redraw(); 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 *)NGETTEXT("block of %ld line yanked%s",
smsg((char_u *)_("1 line yanked%s"), namebuf); "block of %ld lines yanked%s", yanklines),
}
else if (oap->block_mode)
smsg((char_u *)_("block of %ld lines yanked%s"),
yanklines, namebuf); yanklines, namebuf);
}
else 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; curbuf->b_op_start = startpos;
if (change_cnt > p_report) if (change_cnt > p_report)
{ smsg((char_u *)NGETTEXT("%ld line changed", "%ld lines changed",
if (change_cnt == 1) change_cnt), change_cnt);
MSG(_("1 line changed"));
else
smsg((char_u *)_("%ld lines changed"), change_cnt);
}
} }
} }

View File

@@ -794,6 +794,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
306,
/**/ /**/
305, 305,
/**/ /**/

View File

@@ -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 * The _() stuff is for using gettext(). It is a no-op when libintl.h is not
* found or the +multilang feature is disabled. * 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 FEAT_GETTEXT
# ifdef DYNAMIC_GETTEXT # ifdef DYNAMIC_GETTEXT