diff options
author | Sizhe Zhao <prc.zhao@outlook.com> | 2023-01-25 12:53:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-25 12:53:52 +0800 |
commit | 06d1e86ff8e7814e4a648293c1a90414fe82bb1e (patch) | |
tree | ca63a1642624b0dfa7b97897bb816da9f82af8a3 /src/nvim/version.c | |
parent | 377636361728b19bc06671a69b0f42d17352b245 (diff) | |
download | rneovim-06d1e86ff8e7814e4a648293c1a90414fe82bb1e.tar.gz rneovim-06d1e86ff8e7814e4a648293c1a90414fe82bb1e.tar.bz2 rneovim-06d1e86ff8e7814e4a648293c1a90414fe82bb1e.zip |
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.
Diffstat (limited to 'src/nvim/version.c')
-rw-r--r-- | src/nvim/version.c | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/src/nvim/version.c b/src/nvim/version.c index 44f795cdf1..417e5116a5 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -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 (mesg == NULL) { + if (*p != NUL) { + mesg = _(p); + } else { + mesg = ""; } } - if (*p != NUL) { - do_intro_line(row, _(p), 0); + if (*mesg != NUL) { + do_intro_line(row, mesg, 0); } row++; + + if (mesg_size > 0) { + XFREE_CLEAR(mesg); + } } } |