Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-02-26 06:04:16 +0300
committerJunio C Hamano <gitster@pobox.com>2015-02-27 01:09:20 +0300
commit93f7d9108a0edf808e1e3bbcdbe6078310c22f9e (patch)
tree5bfc28011f1988763b56046034bd131a406e962e /gettext.c
parentf18604bbf2c391c689a41fca14cbaeff5e106255 (diff)
gettext.c: move get_preferred_languages() from http.c
Calling setlocale(LC_MESSAGES, ...) directly from http.c, without including <locale.h>, was causing compilation warnings. Move the helper function to gettext.c that already includes the header and where locale-related issues are handled. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gettext.c')
-rw-r--r--gettext.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gettext.c b/gettext.c
index 8b2da4641f..7378ba287f 100644
--- a/gettext.c
+++ b/gettext.c
@@ -18,6 +18,31 @@
# endif
#endif
+/*
+ * Guess the user's preferred languages from the value in LANGUAGE environment
+ * variable and LC_MESSAGES locale category if NO_GETTEXT is not defined.
+ *
+ * The result can be a colon-separated list like "ko:ja:en".
+ */
+const char *get_preferred_languages(void)
+{
+ const char *retval;
+
+ retval = getenv("LANGUAGE");
+ if (retval && *retval)
+ return retval;
+
+#ifndef NO_GETTEXT
+ retval = setlocale(LC_MESSAGES, NULL);
+ if (retval && *retval &&
+ strcmp(retval, "C") &&
+ strcmp(retval, "POSIX"))
+ return retval;
+#endif
+
+ return NULL;
+}
+
#ifdef GETTEXT_POISON
int use_gettext_poison(void)
{