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:
erw7
2019-06-07 13:07:02 +09:00
parent 2d6e440877
commit 1fbc01f4ab
6 changed files with 25 additions and 46 deletions

View File

@@ -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");
}