fix(intro): make :help news line easier to translate (#21974)

Include version number in the translated message so that the word order
can be changed.
Also do not translate URL.
This commit is contained in:
Sizhe Zhao
2023-01-25 12:53:52 +08:00
committed by GitHub
parent 3776363617
commit 06d1e86ff8
4 changed files with 46 additions and 30 deletions

View File

@@ -29,6 +29,7 @@
#include "nvim/highlight_defs.h"
#include "nvim/lua/executor.h"
#include "nvim/mbyte.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option_defs.h"
#include "nvim/os/os_defs.h"
@@ -2789,19 +2790,20 @@ void intro_message(int colon)
long blanklines;
int sponsor;
char *p;
char *mesg;
int mesg_size;
static char *(lines[]) = {
N_(NVIM_VERSION_LONG),
"",
N_("Nvim is open source and freely distributable"),
N_("https://neovim.io/#chat"),
"https://neovim.io/#chat",
"",
N_("type :help nvim<Enter> if you are new! "),
N_("type :checkhealth<Enter> to optimize Nvim"),
N_("type :q<Enter> to exit "),
N_("type :help<Enter> for help "),
"",
N_("type :help news<Enter> to see changes in")
" v" STR(NVIM_VERSION_MAJOR) "." STR(NVIM_VERSION_MINOR),
N_("type :help news<Enter> to see changes in v%s.%s"),
"",
N_("Help poor children in Uganda!"),
N_("type :help iccf<Enter> for information "),
@@ -2833,25 +2835,48 @@ void intro_message(int colon)
if (((row >= 2) && (Columns >= 50)) || colon) {
for (i = 0; i < (int)ARRAY_SIZE(lines); i++) {
p = lines[i];
mesg = NULL;
mesg_size = 0;
if (strstr(p, "news") != NULL) {
p = _(p);
mesg_size = snprintf(NULL, 0, p,
STR(NVIM_VERSION_MAJOR), STR(NVIM_VERSION_MINOR));
assert(mesg_size > 0);
mesg = xmallocz((size_t)mesg_size);
snprintf(mesg, (size_t)mesg_size + 1, p,
STR(NVIM_VERSION_MAJOR), STR(NVIM_VERSION_MINOR));
}
if (sponsor != 0) {
if (strstr(p, "children") != NULL) {
p = sponsor < 0
? N_("Sponsor Vim development!")
: N_("Become a registered Vim user!");
} else if (strstr(p, "iccf") != NULL) {
p = sponsor < 0
? N_("type :help sponsor<Enter> for information ")
: N_("type :help register<Enter> for information ");
} else if (strstr(p, "Orphans") != NULL) {
p = N_("menu Help->Sponsor/Register for information ");
mesg = sponsor < 0
? _("Sponsor Vim development!")
: _("Become a registered Vim user!");
}
if (strstr(p, "iccf") != NULL) {
mesg = sponsor < 0
? _("type :help sponsor<Enter> for information ")
: _("type :help register<Enter> for information ");
}
}
if (*p != NUL) {
do_intro_line(row, _(p), 0);
if (mesg == NULL) {
if (*p != NUL) {
mesg = _(p);
} else {
mesg = "";
}
}
if (*mesg != NUL) {
do_intro_line(row, mesg, 0);
}
row++;
if (mesg_size > 0) {
XFREE_CLEAR(mesg);
}
}
}