mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 7.4.2152
Problem: No proper translation of messages with a count. Solution: Use ngettext(). (Sergey Alyoshin)
This commit is contained in:
@@ -3448,6 +3448,7 @@ f_foldtext(typval_T *argvars UNUSED, typval_T *rettv)
|
|||||||
char_u *r;
|
char_u *r;
|
||||||
int len;
|
int len;
|
||||||
char *txt;
|
char *txt;
|
||||||
|
long count;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
@@ -3478,14 +3479,15 @@ f_foldtext(typval_T *argvars UNUSED, typval_T *rettv)
|
|||||||
s = skipwhite(s + 1);
|
s = skipwhite(s + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txt = _("+-%s%3ld lines: ");
|
count = (long)(foldend - foldstart + 1);
|
||||||
|
txt = ngettext("+-%s%3ld line: ", "+-%s%3ld lines: ", count);
|
||||||
r = alloc((unsigned)(STRLEN(txt)
|
r = alloc((unsigned)(STRLEN(txt)
|
||||||
+ STRLEN(dashes) /* for %s */
|
+ STRLEN(dashes) /* for %s */
|
||||||
+ 20 /* for %3ld */
|
+ 20 /* for %3ld */
|
||||||
+ STRLEN(s))); /* concatenated */
|
+ STRLEN(s))); /* concatenated */
|
||||||
if (r != NULL)
|
if (r != NULL)
|
||||||
{
|
{
|
||||||
sprintf((char *)r, txt, dashes, (long)(foldend - foldstart + 1));
|
sprintf((char *)r, txt, dashes, count);
|
||||||
len = (int)STRLEN(r);
|
len = (int)STRLEN(r);
|
||||||
STRCAT(r, s);
|
STRCAT(r, s);
|
||||||
/* remove 'foldmarker' and 'commentstring' */
|
/* remove 'foldmarker' and 'commentstring' */
|
||||||
@@ -3505,7 +3507,7 @@ f_foldtextresult(typval_T *argvars UNUSED, typval_T *rettv)
|
|||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
linenr_T lnum;
|
linenr_T lnum;
|
||||||
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;
|
||||||
#endif
|
#endif
|
||||||
@@ -3520,8 +3522,7 @@ f_foldtextresult(typval_T *argvars UNUSED, typval_T *rettv)
|
|||||||
fold_count = foldedCount(curwin, lnum, &foldinfo);
|
fold_count = foldedCount(curwin, lnum, &foldinfo);
|
||||||
if (fold_count > 0)
|
if (fold_count > 0)
|
||||||
{
|
{
|
||||||
text = get_foldtext(curwin, lnum, lnum + fold_count - 1,
|
text = get_foldtext(curwin, lnum, lnum + fold_count - 1, &foldinfo, buf);
|
||||||
&foldinfo, buf);
|
|
||||||
if (text == buf)
|
if (text == buf)
|
||||||
text = vim_strsave(text);
|
text = vim_strsave(text);
|
||||||
rettv->vval.v_string = text;
|
rettv->vval.v_string = text;
|
||||||
|
12
src/fold.c
12
src/fold.c
@@ -1853,8 +1853,8 @@ foldDelMarker(linenr_T lnum, char_u *marker, int 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[51]". Otherwise the
|
* When 'foldtext' isn't set puts the result in "buf[FOLD_TEXT_LEN]".
|
||||||
* result is in allocated memory.
|
* Otherwise the result is in allocated memory.
|
||||||
*/
|
*/
|
||||||
char_u *
|
char_u *
|
||||||
get_foldtext(
|
get_foldtext(
|
||||||
@@ -1960,8 +1960,12 @@ get_foldtext(
|
|||||||
if (text == NULL)
|
if (text == NULL)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
sprintf((char *)buf, _("+--%3ld lines folded "),
|
long count = (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;
|
||||||
|
@@ -472,12 +472,15 @@ vimLoadLib(char *name)
|
|||||||
# endif
|
# endif
|
||||||
/* Dummy functions */
|
/* Dummy functions */
|
||||||
static char *null_libintl_gettext(const char *);
|
static char *null_libintl_gettext(const char *);
|
||||||
|
static char *null_libintl_ngettext(const char *, const char *, unsigned long n);
|
||||||
static char *null_libintl_textdomain(const char *);
|
static char *null_libintl_textdomain(const char *);
|
||||||
static char *null_libintl_bindtextdomain(const char *, const char *);
|
static char *null_libintl_bindtextdomain(const char *, const char *);
|
||||||
static char *null_libintl_bind_textdomain_codeset(const char *, const char *);
|
static char *null_libintl_bind_textdomain_codeset(const char *, const char *);
|
||||||
|
|
||||||
static HINSTANCE hLibintlDLL = NULL;
|
static HINSTANCE hLibintlDLL = NULL;
|
||||||
char *(*dyn_libintl_gettext)(const char *) = null_libintl_gettext;
|
char *(*dyn_libintl_gettext)(const char *) = null_libintl_gettext;
|
||||||
|
char *(*dyn_libintl_ngettext)(const char *, const char *, unsigned long n)
|
||||||
|
= null_libintl_ngettext;
|
||||||
char *(*dyn_libintl_textdomain)(const char *) = null_libintl_textdomain;
|
char *(*dyn_libintl_textdomain)(const char *) = null_libintl_textdomain;
|
||||||
char *(*dyn_libintl_bindtextdomain)(const char *, const char *)
|
char *(*dyn_libintl_bindtextdomain)(const char *, const char *)
|
||||||
= null_libintl_bindtextdomain;
|
= null_libintl_bindtextdomain;
|
||||||
@@ -495,6 +498,7 @@ dyn_libintl_init(void)
|
|||||||
} libintl_entry[] =
|
} libintl_entry[] =
|
||||||
{
|
{
|
||||||
{"gettext", (FARPROC*)&dyn_libintl_gettext},
|
{"gettext", (FARPROC*)&dyn_libintl_gettext},
|
||||||
|
{"ngettext", (FARPROC*)&dyn_libintl_ngettext},
|
||||||
{"textdomain", (FARPROC*)&dyn_libintl_textdomain},
|
{"textdomain", (FARPROC*)&dyn_libintl_textdomain},
|
||||||
{"bindtextdomain", (FARPROC*)&dyn_libintl_bindtextdomain},
|
{"bindtextdomain", (FARPROC*)&dyn_libintl_bindtextdomain},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
@@ -553,6 +557,7 @@ dyn_libintl_end(void)
|
|||||||
FreeLibrary(hLibintlDLL);
|
FreeLibrary(hLibintlDLL);
|
||||||
hLibintlDLL = NULL;
|
hLibintlDLL = NULL;
|
||||||
dyn_libintl_gettext = null_libintl_gettext;
|
dyn_libintl_gettext = null_libintl_gettext;
|
||||||
|
dyn_libintl_ngettext = null_libintl_ngettext;
|
||||||
dyn_libintl_textdomain = null_libintl_textdomain;
|
dyn_libintl_textdomain = null_libintl_textdomain;
|
||||||
dyn_libintl_bindtextdomain = null_libintl_bindtextdomain;
|
dyn_libintl_bindtextdomain = null_libintl_bindtextdomain;
|
||||||
dyn_libintl_bind_textdomain_codeset = null_libintl_bind_textdomain_codeset;
|
dyn_libintl_bind_textdomain_codeset = null_libintl_bind_textdomain_codeset;
|
||||||
@@ -565,6 +570,16 @@ null_libintl_gettext(const char *msgid)
|
|||||||
return (char*)msgid;
|
return (char*)msgid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*ARGSUSED*/
|
||||||
|
static char *
|
||||||
|
null_libintl_ngettext(
|
||||||
|
const char *msgid,
|
||||||
|
const char *msgid_plural,
|
||||||
|
unsigned long n)
|
||||||
|
{
|
||||||
|
return n == 1 ? msgid : msgid_plural;
|
||||||
|
}
|
||||||
|
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
static char *
|
static char *
|
||||||
null_libintl_bindtextdomain(const char *domainname, const char *dirname)
|
null_libintl_bindtextdomain(const char *domainname, const char *dirname)
|
||||||
|
@@ -2424,7 +2424,7 @@ fold_line(
|
|||||||
linenr_T lnum,
|
linenr_T lnum,
|
||||||
int row)
|
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;
|
||||||
|
@@ -763,6 +763,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 */
|
||||||
|
/**/
|
||||||
|
2152,
|
||||||
/**/
|
/**/
|
||||||
2151,
|
2151,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -561,6 +561,7 @@ typedef unsigned long u8char_T; /* long should be 32 bits or more */
|
|||||||
# endif
|
# endif
|
||||||
/* These are in os_win32.c */
|
/* These are in os_win32.c */
|
||||||
extern char *(*dyn_libintl_gettext)(const char *msgid);
|
extern char *(*dyn_libintl_gettext)(const char *msgid);
|
||||||
|
extern char *(*dyn_libintl_ngettext)(const char *msgid, const char *msgid_plural, unsigned long n);
|
||||||
extern char *(*dyn_libintl_bindtextdomain)(const char *domainname, const char *dirname);
|
extern char *(*dyn_libintl_bindtextdomain)(const char *domainname, const char *dirname);
|
||||||
extern char *(*dyn_libintl_bind_textdomain_codeset)(const char *domainname, const char *codeset);
|
extern char *(*dyn_libintl_bind_textdomain_codeset)(const char *domainname, const char *codeset);
|
||||||
extern char *(*dyn_libintl_textdomain)(const char *domainname);
|
extern char *(*dyn_libintl_textdomain)(const char *domainname);
|
||||||
@@ -574,6 +575,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
|
|||||||
#ifdef FEAT_GETTEXT
|
#ifdef FEAT_GETTEXT
|
||||||
# ifdef DYNAMIC_GETTEXT
|
# ifdef DYNAMIC_GETTEXT
|
||||||
# define _(x) (*dyn_libintl_gettext)((char *)(x))
|
# define _(x) (*dyn_libintl_gettext)((char *)(x))
|
||||||
|
# define ngettext(x, xs, n) (*dyn_libintl_ngettext)((char *)(x), (char *)(xs), (n))
|
||||||
# define N_(x) x
|
# define N_(x) x
|
||||||
# define bindtextdomain(domain, dir) (*dyn_libintl_bindtextdomain)((domain), (dir))
|
# define bindtextdomain(domain, dir) (*dyn_libintl_bindtextdomain)((domain), (dir))
|
||||||
# define bind_textdomain_codeset(domain, codeset) (*dyn_libintl_bind_textdomain_codeset)((domain), (codeset))
|
# define bind_textdomain_codeset(domain, codeset) (*dyn_libintl_bind_textdomain_codeset)((domain), (codeset))
|
||||||
@@ -592,6 +594,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
|
|||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# define _(x) ((char *)(x))
|
# define _(x) ((char *)(x))
|
||||||
|
# define ngettext(x, xs, n) (((n) == 1) ? (char *)(x) : (char *)(xs))
|
||||||
# define N_(x) x
|
# define N_(x) x
|
||||||
# ifdef bindtextdomain
|
# ifdef bindtextdomain
|
||||||
# undef bindtextdomain
|
# undef bindtextdomain
|
||||||
@@ -1501,6 +1504,8 @@ typedef UINT32_TYPEDEF UINT32_T;
|
|||||||
# define MSG_BUF_CLEN MSG_BUF_LEN /* cell length */
|
# define MSG_BUF_CLEN MSG_BUF_LEN /* cell length */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define FOLD_TEXT_LEN 51 /* buffer size for get_foldtext() */
|
||||||
|
|
||||||
/* Size of the buffer used for tgetent(). Unfortunately this is largely
|
/* Size of the buffer used for tgetent(). Unfortunately this is largely
|
||||||
* undocumented, some systems use 1024. Using a buffer that is too small
|
* undocumented, some systems use 1024. Using a buffer that is too small
|
||||||
* causes a buffer overrun and a crash. Use the maximum known value to stay
|
* causes a buffer overrun and a crash. Use the maximum known value to stay
|
||||||
|
Reference in New Issue
Block a user