vim-patch:7.4.2152

Problem:    No proper translation of messages with a count.
Solution:   Use ngettext(). (Sergey Alyoshin)

ee695f787a
This commit is contained in:
James McCoy 2017-04-15 13:21:38 -04:00
parent f0c12012d9
commit c5d7eaf664
No known key found for this signature in database
GPG Key ID: DFE691AE331BA3DB
5 changed files with 17 additions and 14 deletions

View File

@ -8663,7 +8663,6 @@ static void f_foldtext(typval_T *argvars, typval_T *rettv, FunPtr fptr)
char_u *r; char_u *r;
int len; int len;
char *txt; char *txt;
long count;
rettv->v_type = VAR_STRING; rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL; rettv->vval.v_string = NULL;
@ -8691,8 +8690,8 @@ static void f_foldtext(typval_T *argvars, typval_T *rettv, FunPtr fptr)
s = skipwhite(s + 1); s = skipwhite(s + 1);
} }
} }
count = (long)(foldend - foldstart + 1); unsigned long count = (unsigned long)(foldend - foldstart + 1);
txt = _("+-%s%3ld lines: "); txt = ngettext("+-%s%3ld line: ", "+-%s%3ld lines: ", count);
r = xmalloc(STRLEN(txt) r = xmalloc(STRLEN(txt)
+ STRLEN(dashes) // for %s + STRLEN(dashes) // for %s
+ 20 // for %3ld + 20 // for %3ld
@ -8712,7 +8711,7 @@ static void f_foldtext(typval_T *argvars, typval_T *rettv, FunPtr fptr)
static void f_foldtextresult(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void f_foldtextresult(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{ {
char_u *text; char_u *text;
char_u buf[51]; char_u buf[FOLD_TEXT_LEN];
foldinfo_T foldinfo; foldinfo_T foldinfo;
int fold_count; int fold_count;

View File

@ -1689,12 +1689,10 @@ static void foldDelMarker(linenr_T lnum, char_u *marker, size_t markerlen)
} }
} }
/* get_foldtext() {{{2 */ // get_foldtext() {{{2
/* /// Return the text for a closed fold at line "lnum", with last line "lnume".
* Return the text for a closed fold at line "lnum", with last line "lnume". /// When 'foldtext' isn't set puts the result in "buf[FOLD_TEXT_LEN]".
* When 'foldtext' isn't set puts the result in "buf[51]". Otherwise the /// Otherwise the result is in allocated memory.
* result is in allocated memory.
*/
char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume,
foldinfo_T *foldinfo, char_u *buf) foldinfo_T *foldinfo, char_u *buf)
FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_NONNULL_ARG(1)
@ -1781,8 +1779,12 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume,
} }
} }
if (text == NULL) { if (text == NULL) {
sprintf((char *)buf, _("+--%3ld lines folded "), unsigned long count = (unsigned long)(lnume - lnum + 1);
(long)(lnume - lnum + 1));
vim_snprintf((char *)buf, FOLD_TEXT_LEN,
ngettext("+--%3ld line folded",
"+--%3ld lines folded ", count),
count);
text = buf; text = buf;
} }
return text; return text;

View File

@ -1684,7 +1684,7 @@ static int compute_foldcolumn(win_T *wp, int col)
*/ */
static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T lnum, int row) static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T lnum, int row)
{ {
char_u buf[51]; char_u buf[FOLD_TEXT_LEN];
pos_T *top, *bot; pos_T *top, *bot;
linenr_T lnume = lnum + fold_count - 1; linenr_T lnume = lnum + fold_count - 1;
int len; int len;

View File

@ -289,7 +289,7 @@ static const int included_patches[] = {
// 2155 NA // 2155 NA
// 2154 NA // 2154 NA
// 2153 NA // 2153 NA
// 2152, 2152,
2151, 2151,
// 2150 NA // 2150 NA
2149, 2149,

View File

@ -204,6 +204,8 @@ enum {
#define DIALOG_MSG_SIZE 1000 /* buffer size for dialog_msg() */ #define DIALOG_MSG_SIZE 1000 /* buffer size for dialog_msg() */
enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext()
/* /*
* Maximum length of key sequence to be mapped. * Maximum length of key sequence to be mapped.
* Must be able to hold an Amiga resize report. * Must be able to hold an Amiga resize report.