* Copyright (c) 2010 Ævar Arnfjörð Bjarmason
*/
-#include "git-compat-util.h"
+#include "cache.h"
+#include "exec-cmd.h"
#include "gettext.h"
#include "strbuf.h"
#include "utf8.h"
+#include "config.h"
#ifndef NO_GETTEXT
# include <locale.h>
return NULL;
}
-#ifdef GETTEXT_POISON
int use_gettext_poison(void)
{
static int poison_requested = -1;
- if (poison_requested == -1)
- poison_requested = getenv("GIT_GETTEXT_POISON") ? 1 : 0;
+ if (poison_requested == -1) {
+ const char *v = getenv("GIT_TEST_GETTEXT_POISON");
+ poison_requested = v && strlen(v) ? 1 : 0;
+ }
return poison_requested;
}
-#endif
#ifndef NO_GETTEXT
static int test_vsnprintf(const char *fmt, ...)
void git_setup_gettext(void)
{
- const char *podir = getenv("GIT_TEXTDOMAINDIR");
+ const char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);
+ char *p = NULL;
if (!podir)
- podir = GIT_LOCALE_PATH;
+ podir = p = system_path(GIT_LOCALE_PATH);
+
+ use_gettext_poison(); /* getenv() reentrancy paranoia */
+
+ if (!is_directory(podir)) {
+ free(p);
+ return;
+ }
+
bindtextdomain("git", podir);
setlocale(LC_MESSAGES, "");
setlocale(LC_TIME, "");
init_gettext_charset("git");
textdomain("git");
+
+ free(p);
}
/* return the number of columns of string 's' in current locale */