mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
Fix problems with message catalog directory
- In appimage, the message catalog is not used because there is no message catalog in LOCALE_INSTALL_DIR. Therefore, change to exepath/../share/locale instead of LOCALE_INSTALL_DIR. - The old vim style($runtime/lang) is no longer used. Thus all relevant code is removed.
This commit is contained in:
parent
2d6e440877
commit
1fbc01f4ab
@ -13,7 +13,6 @@
|
||||
#endif
|
||||
|
||||
#define PROJECT_NAME "@PROJECT_NAME@"
|
||||
#define LOCALE_INSTALL_DIR "@CMAKE_INSTALL_FULL_LOCALEDIR@"
|
||||
|
||||
#cmakedefine HAVE__NSGETENVIRON
|
||||
#cmakedefine HAVE_FD_CLOEXEC
|
||||
|
@ -1890,7 +1890,7 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv,
|
||||
}
|
||||
}
|
||||
if (p != NULL) {
|
||||
vim_setenv(name, p);
|
||||
os_setenv(name, p, 1);
|
||||
if (STRICMP(name, "HOME") == 0) {
|
||||
init_homedir();
|
||||
} else if (didset_vim && STRICMP(name, "VIM") == 0) {
|
||||
|
@ -2821,10 +2821,10 @@ void ex_packadd(exarg_T *eap)
|
||||
/// ":options"
|
||||
void ex_options(exarg_T *eap)
|
||||
{
|
||||
vim_setenv("OPTWIN_CMD", cmdmod.tab ? "tab" : "");
|
||||
vim_setenv("OPTWIN_CMD",
|
||||
cmdmod.tab ? "tab" :
|
||||
(cmdmod.split & WSP_VERT) ? "vert" : "");
|
||||
os_setenv("OPTWIN_CMD", cmdmod.tab ? "tab" : "", 1);
|
||||
os_setenv("OPTWIN_CMD",
|
||||
cmdmod.tab ? "tab" :
|
||||
(cmdmod.split & WSP_VERT) ? "vert" : "", 1);
|
||||
cmd_source((char_u *)SYS_OPTWIN_FILE, NULL);
|
||||
}
|
||||
|
||||
@ -3916,19 +3916,19 @@ void ex_language(exarg_T *eap)
|
||||
_nl_msg_cat_cntr++;
|
||||
#endif
|
||||
// Reset $LC_ALL, otherwise it would overrule everything.
|
||||
vim_setenv("LC_ALL", "");
|
||||
os_setenv("LC_ALL", "", 1);
|
||||
|
||||
if (what != LC_TIME) {
|
||||
// Tell gettext() what to translate to. It apparently doesn't
|
||||
// use the currently effective locale.
|
||||
if (what == LC_ALL) {
|
||||
vim_setenv("LANG", (char *)name);
|
||||
os_setenv("LANG", (char *)name, 1);
|
||||
|
||||
// Clear $LANGUAGE because GNU gettext uses it.
|
||||
vim_setenv("LANGUAGE", "");
|
||||
os_setenv("LANGUAGE", "", 1);
|
||||
}
|
||||
if (what != LC_CTYPE) {
|
||||
vim_setenv("LC_MESSAGES", (char *)name);
|
||||
os_setenv("LC_MESSAGES", (char *)name, 1);
|
||||
set_helplang_default((char *)name);
|
||||
}
|
||||
}
|
||||
|
@ -712,22 +712,18 @@ static void init_locale(void)
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
# endif
|
||||
|
||||
# ifdef LOCALE_INSTALL_DIR // gnu/linux standard: $prefix/share/locale
|
||||
bindtextdomain(PROJECT_NAME, LOCALE_INSTALL_DIR);
|
||||
# else // old vim style: $runtime/lang
|
||||
{
|
||||
char_u *p;
|
||||
|
||||
// expand_env() doesn't work yet, because g_chartab[] is not
|
||||
// initialized yet, call vim_getenv() directly
|
||||
p = (char_u *)vim_getenv("VIMRUNTIME");
|
||||
if (p != NULL && *p != NUL) {
|
||||
vim_snprintf((char *)NameBuff, MAXPATHL, "%s/lang", p);
|
||||
bindtextdomain(PROJECT_NAME, (char *)NameBuff);
|
||||
}
|
||||
xfree(p);
|
||||
char localepath[MAXPATHL] = { 0 };
|
||||
char *exepath = localepath;
|
||||
size_t exepathlen = MAXPATHL;
|
||||
if (os_exepath(exepath, &exepathlen) != 0) {
|
||||
path_guess_exepath(argv0 ? argv0 : "nvim", exepath, sizeof(exepath));
|
||||
}
|
||||
# endif
|
||||
char *tail = (char *)path_tail_with_sep((char_u *)exepath);
|
||||
*tail = NUL;
|
||||
tail = (char *)path_tail((char_u *)exepath);
|
||||
xstrlcpy(tail, "share/locale",
|
||||
sizeof(localepath) - (size_t)(tail - localepath));
|
||||
bindtextdomain(PROJECT_NAME, localepath);
|
||||
textdomain(PROJECT_NAME);
|
||||
TIME_MSG("locale set");
|
||||
}
|
||||
|
@ -2598,11 +2598,11 @@ did_set_string_option(
|
||||
} else if (varp == &p_hf) { // 'helpfile'
|
||||
// May compute new values for $VIM and $VIMRUNTIME
|
||||
if (didset_vim) {
|
||||
vim_setenv("VIM", "");
|
||||
os_setenv("VIM", "", 1);
|
||||
didset_vim = false;
|
||||
}
|
||||
if (didset_vimruntime) {
|
||||
vim_setenv("VIMRUNTIME", "");
|
||||
os_setenv("VIMRUNTIME", "", 1);
|
||||
didset_vimruntime = false;
|
||||
}
|
||||
} else if (varp == &curwin->w_p_cc) { // 'colorcolumn'
|
||||
@ -6744,7 +6744,7 @@ void vimrc_found(char_u *fname, char_u *envname)
|
||||
// Set $MYVIMRC to the first vimrc file found.
|
||||
p = FullName_save((char *)fname, false);
|
||||
if (p != NULL) {
|
||||
vim_setenv((char *)envname, p);
|
||||
os_setenv((char *)envname, p, 1);
|
||||
xfree(p);
|
||||
}
|
||||
} else {
|
||||
|
@ -805,10 +805,10 @@ char *vim_getenv(const char *name)
|
||||
// next time, and others can also use it (e.g. Perl).
|
||||
if (vim_path != NULL) {
|
||||
if (vimruntime) {
|
||||
vim_setenv("VIMRUNTIME", vim_path);
|
||||
os_setenv("VIMRUNTIME", vim_path, 1);
|
||||
didset_vimruntime = true;
|
||||
} else {
|
||||
vim_setenv("VIM", vim_path);
|
||||
os_setenv("VIM", vim_path, 1);
|
||||
didset_vim = true;
|
||||
}
|
||||
}
|
||||
@ -955,22 +955,6 @@ char_u * home_replace_save(buf_T *buf, char_u *src) FUNC_ATTR_NONNULL_RET
|
||||
return dst;
|
||||
}
|
||||
|
||||
/// Vim setenv() wrapper with special handling for $VIMRUNTIME to keep the
|
||||
/// localization machinery sane.
|
||||
void vim_setenv(const char *name, const char *val)
|
||||
{
|
||||
os_setenv(name, val, 1);
|
||||
#ifndef LOCALE_INSTALL_DIR
|
||||
// When setting $VIMRUNTIME adjust the directory to find message
|
||||
// translations to $VIMRUNTIME/lang.
|
||||
if (*val != NUL && STRICMP(name, "VIMRUNTIME") == 0) {
|
||||
char *buf = (char *)concat_str((char_u *)val, (char_u *)"/lang");
|
||||
bindtextdomain(PROJECT_NAME, buf);
|
||||
xfree(buf);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/// Function given to ExpandGeneric() to obtain an environment variable name.
|
||||
char_u *get_env_name(expand_T *xp, int idx)
|
||||
|
Loading…
Reference in New Issue
Block a user