Skip to content

Commit 68f5458

Browse files
committed
gettext: handle GIT_TEXTDOMAINDIR relative to $(prefix)
On Windows, there is no single root directory. And what Git thinks is a root directory is not a root directory at all: everything is relative to the location where Git is installed. To handle this situation better, let's just allow for GIT_TEXTDOMAINDIR to be a path relative to the (runtime) prefix. To that end, we have to switch the order in which common-main handles argv0 and sets up gettext: in order to have access to the runtime prefix, we need it to be inferred from argv0 already. This patch also prepares for GIT_LOCALE_PATH to be relative to prefix, which is the even more important fix. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 8809b9e commit 68f5458

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

common-main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ int main(int argc, const char **argv)
3232
*/
3333
sanitize_stdfds();
3434

35+
git_extract_argv0_path(argv[0]);
36+
3537
git_setup_gettext();
3638

3739
attr_start();
3840

39-
git_extract_argv0_path(argv[0]);
40-
4141
restore_sigpipe_to_default();
4242

4343
return cmd_main(argc, argv);

gettext.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "gettext.h"
77
#include "strbuf.h"
88
#include "utf8.h"
9+
#include "cache.h"
10+
#include "exec_cmd.h"
911

1012
#ifndef NO_GETTEXT
1113
# include <locale.h>
@@ -158,14 +160,20 @@ static void init_gettext_charset(const char *domain)
158160
void git_setup_gettext(void)
159161
{
160162
const char *podir = getenv("GIT_TEXTDOMAINDIR");
163+
char *p = NULL;
161164

162165
if (!podir)
163166
podir = GIT_LOCALE_PATH;
167+
if (!is_absolute_path(podir))
168+
podir = p = system_path(podir);
169+
164170
bindtextdomain("git", podir);
165171
setlocale(LC_MESSAGES, "");
166172
setlocale(LC_TIME, "");
167173
init_gettext_charset("git");
168174
textdomain("git");
175+
176+
free(p);
169177
}
170178

171179
/* return the number of columns of string 's' in current locale */

0 commit comments

Comments
 (0)