Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel
authorWilfried Goesgens <dothebart@citadel.org>
Tue, 21 Feb 2012 22:47:25 +0000 (23:47 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Tue, 21 Feb 2012 22:47:25 +0000 (23:47 +0100)
webcit/gettext.c
webcit/webserver.c

index 5ae10394584427297d9797e9d397d1f76379b6cc..25474e810c5b8f68eb2f521cdc90de0be6dbb3ad 100644 (file)
@@ -280,9 +280,6 @@ void stop_selected_language(void) {
 #endif
 }
 
-#ifdef HAVE_USELOCALE
-       locale_t Empty_Locale;
-#endif
 
 /*
  * Create a locale_t for each available language
@@ -290,9 +287,15 @@ void stop_selected_language(void) {
 void initialize_locales(void) {
        int nLocales;
        int i;
-       char buf[32];
        char *language = NULL;
 
+#ifdef ENABLE_NLS
+       setlocale(LC_ALL, "");
+       syslog(9, "Text domain: %s", textdomain("webcit"));
+       syslog(9, "Message catalog directory: %s", bindtextdomain(textdomain(NULL), LOCALEDIR"/locale"));
+       syslog(9, "Text domain Charset: %s", bind_textdomain_codeset("webcit","UTF8"));
+#endif
+
        nLocales = 0; 
        while (!IsEmptyStr(AvailLang[nLocales]))
                nLocales++;
@@ -308,42 +311,38 @@ void initialize_locales(void) {
 #ifdef HAVE_USELOCALE
        wc_locales = malloc (sizeof(locale_t) * nLocales);
        memset(wc_locales,0, sizeof(locale_t) * nLocales);
-       /* create default locale */
-       Empty_Locale = newlocale(LC_ALL_MASK, NULL, NULL);
+       wc_locales[0] = newlocale(LC_ALL_MASK, NULL, NULL);
 #endif
 
-       for (i = 0; i < nLocales; ++i) {
-               if ((language != NULL) && (strcmp(AvailLang[i], language) != 0))
-                       continue;
-               if (i == 0) {
-                       sprintf(buf, "%s", AvailLang[i]);       /* locale 0 (C) is ascii, not utf-8 */
-               }
-               else {
-                       sprintf(buf, "%s.UTF8", AvailLang[i]);
-               }
+       for (i = 1; i < nLocales; ++i) {
 #ifdef HAVE_USELOCALE
                wc_locales[nLocalesLoaded] = newlocale(
                        (LC_MESSAGES_MASK|LC_TIME_MASK),
-                       buf,
-                       (((i > 0) && (wc_locales[0] != NULL)) ? wc_locales[0] : Empty_Locale)
+                       AvailLang[i],
+                       wc_locales[0]
                );
                if (wc_locales[nLocalesLoaded] == NULL) {
-                       syslog(1, "locale for %s disabled: %s", buf, strerror(errno));
+                       syslog(1, "locale for %s disabled: %s (domain: %s, path: %s)",
+                               AvailLang[i],
+                               strerror(errno),
+                               textdomain(NULL),
+                               bindtextdomain(textdomain(NULL), NULL)
+                       );
                }
                else {
-                       syslog(3, "Found locale: %s", buf);
+                       syslog(3, "Found locale: %s", AvailLang[i]);
                        AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
                        nLocalesLoaded++;
                }
 #else
                if ((language != NULL) && (strcmp(language, AvailLang[i]) == 0)) {
-                       setenv("LANG", buf, 1);
+                       setenv("LANG", AvailLang[i], 1);
                        AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
                        setlocale(LC_MESSAGES, AvailLang[i]);
                        nLocalesLoaded++;
                }
                else if (nLocalesLoaded == 0) {
-                       setenv("LANG", buf, 1);
+                       setenv("LANG", AvailLang[i], 1);
                        AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
                        nLocalesLoaded++;
                }
@@ -351,26 +350,13 @@ void initialize_locales(void) {
        }
        if ((language != NULL) && (nLocalesLoaded == 0)) {
                syslog(1, "Your selected locale [%s] isn't available on your system. falling back to C", language);
-#ifdef HAVE_USELOCALE
-               wc_locales[0] = newlocale(
-                       (LC_MESSAGES_MASK|LC_TIME_MASK),
-                       AvailLang[0],
-                       Empty_Locale
-               );
-#else
+#ifndef HAVE_USELOCALE
                setlocale(LC_MESSAGES, AvailLang[0]);
                setenv("LANG", AvailLang[0], 1);
 #endif
                AvailLangLoaded[0] = AvailLang[0];
                nLocalesLoaded = 1;
        }
-
-#ifdef ENABLE_NLS
-       setlocale(LC_ALL, "");
-       syslog(9, "Message catalog directory: %s", bindtextdomain("webcit", LOCALEDIR"/locale"));
-       syslog(9, "Text domain: %s", textdomain("webcit"));
-       syslog(9, "Text domain Charset: %s", bind_textdomain_codeset("webcit","UTF8"));
-#endif
 }
 
 
@@ -381,9 +367,7 @@ ServerShutdownModule_GETTEXT
 #ifdef HAVE_USELOCALE
        int i;
        for (i = 0; i < nLocalesLoaded; ++i) {
-               if (Empty_Locale != wc_locales[i]) {
-                       freelocale(wc_locales[i]);
-               }
+               freelocale(wc_locales[i]);
        }
        free(wc_locales);
 #endif
index 3a896b4726e7cc37fdea541ed8808d8e032a7e37..c618e540265750d82ffad7ba256358fc110221c4 100644 (file)
@@ -233,19 +233,13 @@ int main(int argc, char **argv)
        syslog(1, "Copyright (C) 1996-2012 by the citadel.org team");
        syslog(1, " ");
        syslog(1, "This program is open source software: you can redistribute it and/or");
-       syslog(1, "modify it under the terms of the GNU General Public License as published");
-       syslog(1, "by the Free Software Foundation, either version 3 of the License, or");
-       syslog(1, "(at your option) any later version.");
+       syslog(1, "modify it under the terms of the GNU General Public License, version 3.");
        syslog(1, " ");
        syslog(1, "This program is distributed in the hope that it will be useful,");
        syslog(1, "but WITHOUT ANY WARRANTY; without even the implied warranty of");
        syslog(1, "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the");
        syslog(1, "GNU General Public License for more details.");
        syslog(1, " ");
-       syslog(1, "You should have received a copy of the GNU General Public License");
-       syslog(1, "along with this program.  If not, see <http://www.gnu.org/licenses/>.");
-       syslog(1, " ");
-
 
        /* initialize various subsystems */