* fixed langage detection to work with simple 'de' and no other stuff
authorWilfried Göesgens <willi@citadel.org>
Sat, 3 Dec 2005 12:04:12 +0000 (12:04 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sat, 3 Dec 2005 12:04:12 +0000 (12:04 +0000)
webcit/ChangeLog
webcit/gettext.c

index 05e0b7bf2f0cd332a8a3ff397b660fdc5e13e070..5818e2657f3343c9b7f341f5c92751dd25701a32 100644 (file)
@@ -1,5 +1,8 @@
 $Id$
 
+Sat Dec 3 10:28:03 CET 2005 dothebart
+* fixed langage detection to work with simple 'de' and no other stuff
+
 Fri Dec  2 17:49:32 EST 2005 ajc
 * Re-enabled browser language detection.  This will be debugged and finalized.
 
index 29a3ea98e823d38e92bc5a3920628d5ebfa86589..0f857c390e2faee6a31a99165a3b7583c7aafa51 100644 (file)
@@ -25,18 +25,19 @@ void httplang_to_locale(const char *LocaleString)
        //      char *webcitdir = WEBCITDIR;
        locale_t my_Locale;
        locale_t my_Empty_Locale;
+
+       //      len = strlen(LocaleString);
        memcpy(search, LocaleString, len);
-       search[len + 1] = '\0';
-       len = strlen(search);
+       search[len] = '\0';
        /* the web browser sends '-', we need '_' */
        for (i = 0; i < len; i++)
                if (search[i] == '-')
                        search[i] = '_';
        i = 0;
-       while ((search[i] != '\0') && !done && (nFound < 10)) {
-               if ((search[i] == ',') || (search[i] == ';'))
+       while ( !done && (nFound < 10)) {
+               if ((search[i] == ',') || (search[i] == ';') || (search[i] == '\0'))
                {
-                       if (search[i] == ';')
+                       if ((search[i] == ';') || (search[i] == '\0'))
                                done = 1;
                        search[i] = '\0';
                        wanted_locales[nFound] = (char *) &search[j];
@@ -48,7 +49,7 @@ void httplang_to_locale(const char *LocaleString)
        }
        /* todo: weight  */
 
-       for (i = 0; i <= nFound; i++) {
+       if (nFound > 0) for (i = 0; i <= nFound; i++) {
                for (j = 0; j < nAvail; j++) {
                        int ret = strncasecmp(wanted_locales[i],
                                              AvailLang[j],