1
0
forked from aniani/vim

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)
{
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
{

View 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);

View 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;

View 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);
}
}

View 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))

View File

@@ -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 *)">";
op = ">";
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);
}
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);
}
}

View File

@@ -794,6 +794,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
306,
/**/
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
* 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