1 #include "exec_cmd.h"
2 #include <locale.h>
3 #include <libintl.h>
4 #ifdef HAVE_LIBCHARSET_H
5 #include <libcharset.h>
6 #else
7 #include <langinfo.h>
8 #endif
9 #include <stdlib.h>
11 extern void git_setup_gettext(void) {
12 char *podir;
13 char *envdir = getenv("GIT_TEXTDOMAINDIR");
14 const char *charset;
16 if (envdir) {
17 (void)bindtextdomain("git", envdir);
18 } else {
19 podir = (char *)system_path("share/locale");
20 if (!podir) return;
21 (void)bindtextdomain("git", podir);
22 free(podir);
23 }
25 (void)setlocale(LC_MESSAGES, "");
26 (void)setlocale(LC_CTYPE, "");
27 #ifdef HAVE_LIBCHARSET_H
28 charset = locale_charset();
29 #else
30 charset = nl_langinfo(CODESET);
31 #endif
32 (void)bind_textdomain_codeset("git", charset);
33 (void)setlocale(LC_CTYPE, "C");
34 (void)textdomain("git");
35 }