]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Display locale information for debugging purpose
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Thu, 11 Dec 2014 14:01:23 +0000 (15:01 +0100)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Fri, 12 Dec 2014 16:06:06 +0000 (17:06 +0100)
Running sarg -x -v display the version number but also the directory where
the message file is looked for, the package name and the currently
selected locale.

log.c
util.c

diff --git a/log.c b/log.c
index 7479d8b4711bb34f00854e6ac8d7f04211da532b..89254e840d527ab67efed286c7eb15bb80b28d76 100644 (file)
--- a/log.c
+++ b/log.c
@@ -43,6 +43,9 @@ struct ReadLogDataStruct ReadFilter;
 FileListObject AccessLog=NULL;
 
 
+//! Selected locale set through the environment variable.
+char *CurrentLocale=NULL;
+
 static void getusers(const char *pwdfile, int debug);
 
 int main(int argc,char *argv[])
@@ -97,7 +100,8 @@ int main(int argc,char *argv[])
 #endif
 
 #if defined(ENABLE_NLS) && defined(HAVE_LOCALE_H)
-       if (!setlocale (LC_ALL, "")) {
+       CurrentLocale=setlocale (LC_ALL, "");
+       if (!CurrentLocale) {
                fprintf(stderr,"SARG: Cannot set the locale LC_ALL to the environment variable\n");
                exit(EXIT_FAILURE);
        }
diff --git a/util.c b/util.c
index 0511b3565d7571f6ed06897bbda7ce88deb8868c..f5c749e6d65bdae1fa4cba272eba4137b1d39965 100644 (file)
--- a/util.c
+++ b/util.c
@@ -41,6 +41,8 @@ static char mtab1[12][4]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep",
 //! The list of the HTTP codes to exclude from the report.
 static char *excludecode=NULL;
 
+extern char *CurrentLocale;
+
 #if USE_GETWORD_BACKTRACE
 static void getword_backtrace(void)
 {
@@ -2076,6 +2078,12 @@ void url_to_anchor(const char *url,char *anchor,int size)
 void version(void)
 {
        printf(_("SARG Version: %s\n"),VERSION);
+#if defined(ENABLE_NLS) && defined(HAVE_LOCALE_H)
+       if (debug) {
+               printf(_("Translation file should be somewhere under \"%s\" and be named \"%s.mo\"\n"),LOCALEDIR,PACKAGE_NAME);
+               if (CurrentLocale) printf(_("The currently selected locale is \"%s\"\n"),CurrentLocale);
+       }
+#endif
        exit(EXIT_SUCCESS);
 }