* Re-enabled browser language detection. This will be debugged and finalized.
authorArt Cancro <ajc@citadel.org>
Fri, 2 Dec 2005 22:50:30 +0000 (22:50 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 2 Dec 2005 22:50:30 +0000 (22:50 +0000)
webcit/ChangeLog
webcit/auth.c
webcit/context_loop.c
webcit/gettext.c
webcit/po/de.po
webcit/po/webcit.pot
webcit/static/login.html

index 231b1ce6855dfb04615d6219befb9e47dc26dbb9..05e0b7bf2f0cd332a8a3ff397b660fdc5e13e070 100644 (file)
@@ -1,5 +1,8 @@
 $Id$
 
+Fri Dec  2 17:49:32 EST 2005 ajc
+* Re-enabled browser language detection.  This will be debugged and finalized.
+
 Fri Dec  2 11:01:30 EST 2005 ajc
 * wclib.js: fixed a syntax error
 
index 6ba3d95e4b0b5fc7f0a6ddfd83ec44328a8f3423..7b1733b3b0f5900fbb4f227437296949bf3c7a97 100644 (file)
@@ -20,6 +20,24 @@ void initialize_axdefs(void) {
 }
 
 
+/*
+ * Offer available languages in the login box
+ */
+void offer_languages(void) {
+
+#ifdef ENABLE_NLS
+
+wprintf("FIXME");
+
+#else /* ENABLE_NLS */
+
+wprintf("US English");
+
+#endif /* ENABLE_NLS */
+
+}
+
+
 /*
  * Display the login screen
  */
@@ -54,12 +72,14 @@ void display_login(char *mesg)
 
        svprintf("USERNAME_BOX", WCS_STRING, "%s", _("User name:"));
        svprintf("PASSWORD_BOX", WCS_STRING, "%s", _("Password:"));
+       svprintf("LANGUAGE_BOX", WCS_STRING, "%s", _("Language:"));
        svprintf("LOGIN_BUTTON", WCS_STRING, "%s", _("Login"));
        svprintf("NEWUSER_BUTTON", WCS_STRING, "%s", _("New User"));
        svprintf("EXIT_BUTTON", WCS_STRING, "%s", _("Exit"));
        svprintf("hello", WCS_SERVCMD, "MESG hello");
        svprintf("BOXTITLE", WCS_STRING, _("%s - powered by Citadel"),
                serv_info.serv_humannode);
+       svcallback("DO_LANGUAGE_BOX", offer_languages);
 
        do_template("login");
 
index 1223ae5f21b1c81ed2dadf7213f12fd896598e14..1667fdc195765f0ae6ef85c60744a5d99d752e50 100644 (file)
@@ -246,9 +246,10 @@ void context_loop(int sock)
        int got_cookie = 0;
        int gzip_ok = 0;
        struct wcsession *TheSession, *sptr;
-       char httpauth_string[SIZ];
-       char httpauth_user[SIZ];
-       char httpauth_pass[SIZ];
+       char httpauth_string[1024];
+       char httpauth_user[1024];
+       char httpauth_pass[1024];
+       char accept_language[256];
        char *ptr = NULL;
 
        strcpy(httpauth_string, "");
@@ -293,9 +294,11 @@ void context_loop(int sock)
                        if_modified_since = httpdate_to_timestamp(&buf[19]);
                }
 
-               /*if (!strncasecmp(buf, "Accept-Language: ", 17)) {
-                       httplang_to_locale(&buf[17]);
-               }*/
+#ifdef ENABLE_NLS
+               if (!strncasecmp(buf, "Accept-Language: ", 17)) {
+                       safestrncpy(accept_language, &buf[17], sizeof accept_language);
+               }
+#endif
 
                /*
                 * Read in the request
@@ -431,6 +434,9 @@ void context_loop(int sock)
        TheSession->http_sock = sock;
        TheSession->lastreq = time(NULL);                       /* log */
        TheSession->gzip_ok = gzip_ok;
+#ifdef ENABLE_NLS
+       httplang_to_locale(accept_language);    /* FIXME do more here */
+#endif /* ENABLE_NLS */
        session_loop(req);                              /* do transaction */
        pthread_mutex_unlock(&TheSession->SessionMutex);        /* unbind */
 
index f5e5a331b551fca01ae823dea5fa9478542f46bf..29a3ea98e823d38e92bc5a3920628d5ebfa86589 100644 (file)
@@ -2,86 +2,79 @@
 #include "webcit.h"
 #include "webserver.h"
 
-static const char* AvailLang[]=
-       {
-               "de_DE"
+#ifdef ENABLE_NLS
 
-       };
+static const char *AvailLang[] = {
+       "de_DE"
+};
 
 /* TODO: we skip the language weightening so far. */
 /* Accept-Language: 'de-de,en-us;q=0.7,en;q=0.3' */
-void httplang_to_locale(const charLocaleString)
+void httplang_to_locale(const char *LocaleString)
 {
-       char *locale="C";
+       char *locale = "C";
        char *wanted_locales[10];
-       int i=0;
-       int j=0;
-       size_t len=strlen(LocaleString);
-       int nFound=0;
-       int nAvail=1;
-       char *search=(char*)malloc(len);
-       int done=0;
-       //      char *mo;
-       //      char *webcitdir = WEBCITDIR;
+       int i = 0;
+       int j = 0;
+       size_t len = strlen(LocaleString);
+       int nFound = 0;
+       int nAvail = 1;
+       char *search = (char *) malloc(len);
+       int done = 0;
+       //      char *mo;
+       //      char *webcitdir = WEBCITDIR;
        locale_t my_Locale;
        locale_t my_Empty_Locale;
-       memcpy(search,LocaleString,len);
-       search[len+1]='\0';
-       len=strlen(search);
+       memcpy(search, LocaleString, len);
+       search[len + 1] = '\0';
+       len = strlen(search);
        /* 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))
+       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] == ';'))
                {
-                       if ((search[i]==',')||(search[i]==';'))
-               
-                               {
-                                       if (search[i]==';') done=1;
-                                       search[i]='\0';
-                                       wanted_locales[nFound]=(char*)&search[j];
-                                       j=i+1;
-                                       nFound++;
-                               }
-                       
-                       i++;
+                       if (search[i] == ';')
+                               done = 1;
+                       search[i] = '\0';
+                       wanted_locales[nFound] = (char *) &search[j];
+                       j = i + 1;
+                       nFound++;
                }
+
+               i++;
+       }
        /* todo: weight  */
 
-       for (i=0; i<=nFound; i++)
-               {
-                       for (j=0;j<nAvail; j++)
-                               {
-                                       int ret=strncasecmp(wanted_locales[i],
-                                                                               AvailLang[j],
-                                                                               strlen(wanted_locales[i]));
-                                       if (!ret)
-                                               {
-                                                       locale=(char*)AvailLang[j]; //wanted_locales[i];
-                                                       i=nFound+1;
-                                                       j=nAvail+1;
-                                                       continue;
-                                               }
+       for (i = 0; i <= nFound; i++) {
+               for (j = 0; j < nAvail; j++) {
+                       int ret = strncasecmp(wanted_locales[i],
+                                             AvailLang[j],
+                                             strlen(wanted_locales[i]));
+                       if (!ret) {
+                               locale = (char *) AvailLang[j]; //wanted_locales[i];
+                               i = nFound + 1;
+                               j = nAvail + 1;
+                               continue;
+                       }
 
-                               }
                }
-       
-       len=strlen(locale);
-       memcpy(search,locale,len);
-       memcpy(&search[len],".UTF8",5);
-       search[len+5]='\0';
-       my_Empty_Locale=newlocale(LC_ALL_MASK, NULL, NULL); /* create default locale */
-       my_Locale=newlocale(LC_MESSAGES_MASK/*|LC_TIME_MASK TODO */,
-                                          search,
-                                          my_Empty_Locale);
+       }
+
+       len = strlen(locale);
+       memcpy(search, locale, len);
+       memcpy(&search[len], ".UTF8", 5);
+       search[len + 5] = '\0';
+       my_Empty_Locale = newlocale(LC_ALL_MASK, NULL, NULL);   /* create default locale */
+       my_Locale = newlocale(LC_MESSAGES_MASK /*|LC_TIME_MASK FIXME */ ,
+                             search, my_Empty_Locale);
 
        uselocale(my_Locale);
-       //freelocale(my_Locale);
-       //      freelocale(my_Empty_Locale);
+       //      freelocale(my_Locale);
+       //      freelocale(my_Empty_Locale);
        free(search);
-
 }
 
+#endif
index b2a6b8bd156628b5c3beaea6446bb77f4ed4b9d8..81eb28b162f5a1812caf9fcb4e1778ff2a8e3f0a 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2005-12-01 00:24-0500\n"
+"POT-Creation-Date: 2005-12-02 17:03-0500\n"
 "PO-Revision-Date: 2005-11-13 15:22+100\n"
 "Last-Translator: Wilfried Goesgens <w.goesgens@chaosindustries.de>\n"
 "Language-Team: German <LL@li.org>\n"
@@ -21,7 +21,7 @@ msgstr ""
 msgid "Deleted"
 msgstr "Löschen"
 
-#: ../auth.c:14 ../auth.c:58
+#: ../auth.c:14 ../auth.c:77
 msgid "New User"
 msgstr "Neuer Benutzer"
 
@@ -49,7 +49,7 @@ msgstr "nur Privilegierte Benutzer"
 msgid "Aide"
 msgstr "Mittelinitial"
 
-#: ../auth.c:39
+#: ../auth.c:57
 #, c-format
 msgid ""
 "<ul><li><b>If you already have an account on %s</b>, enter your user name "
@@ -71,37 +71,41 @@ msgstr ""
 "fallen</li>\n"
 "<br /></ul>"
 
-#: ../auth.c:55 ../who.c:258
+#: ../auth.c:73 ../who.c:258
 msgid "User name:"
 msgstr "Benutzername:"
 
-#: ../auth.c:56
+#: ../auth.c:74
 #, fuzzy
 msgid "Password:"
 msgstr "Passwort"
 
-#: ../auth.c:57
+#: ../auth.c:75
+msgid "Language:"
+msgstr ""
+
+#: ../auth.c:76
 msgid "Login"
 msgstr "Anmelden"
 
-#: ../auth.c:59 ../paging.c:474
+#: ../auth.c:78 ../paging.c:474
 msgid "Exit"
 msgstr "Ende"
 
-#: ../auth.c:61
+#: ../auth.c:80
 #, c-format
 msgid "%s - powered by Citadel"
 msgstr "%s - mit Citadel-Technologie"
 
-#: ../auth.c:132 ../auth.c:470
+#: ../auth.c:157 ../auth.c:503
 msgid "Blank passwords are not allowed."
 msgstr "Leere Passwörter sind nicht zulässig."
 
-#: ../auth.c:153
+#: ../auth.c:178
 msgid "Your password was not accepted."
 msgstr "Ihr Passwort wurde nicht akzeptiert"
 
-#: ../auth.c:245
+#: ../auth.c:278
 msgid ""
 "This program was unable to connect or stay connected to the Citadel server.  "
 "Please report this problem to your system administrator."
@@ -109,40 +113,40 @@ msgstr ""
 "Dieses Programm konnte keine Verbindung zum Citadel-Server herstellen oder "
 "aufrechterhalten.Bitte wenden Sie sich an Ihren Administrator."
 
-#: ../auth.c:253
+#: ../auth.c:286
 msgid "Close window"
 msgstr "Fenster Schließen"
 
-#: ../auth.c:274 ../mainmenu.c:239
+#: ../auth.c:307 ../mainmenu.c:239
 msgid "Validate new users"
 msgstr "Neue Benutzer überprüfen"
 
-#: ../auth.c:325
+#: ../auth.c:358
 #, c-format
 msgid "Current access level: %d (%s)\n"
 msgstr "Aktuelle Berechtigungen: %d (%s)\n"
 
-#: ../auth.c:333
+#: ../auth.c:366
 msgid "Select access level for this user:"
 msgstr "Berechtigungen dieses Benutzers"
 
-#: ../auth.c:395 ../mainmenu.c:135
+#: ../auth.c:428 ../mainmenu.c:135
 msgid "Change your password"
 msgstr "Ändern Sie Ihr Passwort"
 
-#: ../auth.c:424
+#: ../auth.c:457
 msgid "Enter new password:"
 msgstr "Bitte geben Sie ein neues Passwort ein"
 
-#: ../auth.c:428
+#: ../auth.c:461
 msgid "Enter it again to confirm:"
 msgstr "Nocheinmal zur Verifizierung:"
 
-#: ../auth.c:433
+#: ../auth.c:466
 msgid "Change password"
 msgstr "Passwort ändern"
 
-#: ../auth.c:435 ../calendar.c:582 ../event.c:385 ../graphics.c:57
+#: ../auth.c:468 ../calendar.c:582 ../event.c:385 ../graphics.c:57
 #: ../iconbar.c:699 ../mainmenu.c:298 ../messages.c:2590 ../messages.c:2693
 #: ../messages.c:2777 ../netconf.c:79 ../netconf.c:139 ../paging.c:56
 #: ../preferences.c:361 ../roomops.c:1162 ../roomops.c:1489 ../roomops.c:1917
@@ -151,11 +155,11 @@ msgstr "Passwort ändern"
 msgid "Cancel"
 msgstr "Abbruch"
 
-#: ../auth.c:451
+#: ../auth.c:484
 msgid "Cancelled.  Password was not changed."
 msgstr "Abgebrochen. Passwort wurde nicht gesetzt."
 
-#: ../auth.c:462
+#: ../auth.c:495
 msgid "They don't match.  Password was not changed."
 msgstr "Die Passwörter stimmen nicht überein. Passwort nicht geändert"
 
@@ -581,11 +585,11 @@ msgstr "Sie haben keine Datei hochgeladen."
 msgid "realloc() error! couldn't get %d bytes: %s"
 msgstr "realloc() Fehler! Konnte %d Bytes nicht alloziieren: %s"
 
-#: ../iconbar.c:97 ../iconbar.c:391
+#: ../iconbar.c:97 ../iconbar.c:381
 msgid "Find out more about Citadel"
 msgstr "Mehr über Citadel herausfinden"
 
-#: ../iconbar.c:98 ../iconbar.c:392
+#: ../iconbar.c:98 ../iconbar.c:382
 msgid "CITADEL"
 msgstr "CITADEL"
 
@@ -671,23 +675,24 @@ msgstr "Räume und Verwaltung"
 msgid "Administration"
 msgstr "Verwaltung"
 
-#: ../iconbar.c:300 ../iconbar.c:309 ../mainmenu.c:108
+#: ../iconbar.c:299 ../iconbar.c:308 ../iconbar.c:392 ../iconbar.c:401
+#: ../mainmenu.c:108
 msgid "Log off"
 msgstr "Abmelden"
 
-#: ../iconbar.c:301
+#: ../iconbar.c:300 ../iconbar.c:393
 msgid "Log off now?"
 msgstr "Jetzt abmelden?"
 
-#: ../iconbar.c:320
+#: ../iconbar.c:318
 msgid "Customize this menu"
 msgstr "Dieses Menü bearbeiten"
 
-#: ../iconbar.c:321
+#: ../iconbar.c:319
 msgid "customize this menu"
 msgstr "Dieses Menü Bearbeiten"
 
-#: ../iconbar.c:396
+#: ../iconbar.c:386
 #, fuzzy
 msgid "switch to menu"
 msgstr "Zurück zum Menü"
@@ -1811,7 +1816,7 @@ msgstr "Die Systemvorgabe benutzen"
 msgid "Expire by message count"
 msgstr "Nachrichten nach Anzahl löschen"
 
-#: ../roomops.c:1541 ../roomops.c:2843
+#: ../roomops.c:1541 ../roomops.c:2880
 msgid "Cancelled.  Changes were not saved."
 msgstr "Abgebrochen. Änderungen wurden nicht übernommen."
 
index 1ba69c386456e73f1e740b235064c0c322681b66..4a9ab7461d53ea7f8b1ac7cfb5efd5fbf6523d40 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2005-12-01 00:24-0500\n"
+"POT-Creation-Date: 2005-12-02 17:03-0500\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -20,7 +20,7 @@ msgstr ""
 msgid "Deleted"
 msgstr ""
 
-#: ../auth.c:14 ../auth.c:58
+#: ../auth.c:14 ../auth.c:77
 msgid "New User"
 msgstr ""
 
@@ -44,7 +44,7 @@ msgstr ""
 msgid "Aide"
 msgstr ""
 
-#: ../auth.c:39
+#: ../auth.c:57
 #, c-format
 msgid ""
 "<ul><li><b>If you already have an account on %s</b>, enter your user name "
@@ -56,75 +56,79 @@ msgid ""
 "receive any instant messages.<br /></ul>"
 msgstr ""
 
-#: ../auth.c:55 ../who.c:258
+#: ../auth.c:73 ../who.c:258
 msgid "User name:"
 msgstr ""
 
-#: ../auth.c:56
+#: ../auth.c:74
 msgid "Password:"
 msgstr ""
 
-#: ../auth.c:57
+#: ../auth.c:75
+msgid "Language:"
+msgstr ""
+
+#: ../auth.c:76
 msgid "Login"
 msgstr ""
 
-#: ../auth.c:59 ../paging.c:474
+#: ../auth.c:78 ../paging.c:474
 msgid "Exit"
 msgstr ""
 
-#: ../auth.c:61
+#: ../auth.c:80
 #, c-format
 msgid "%s - powered by Citadel"
 msgstr ""
 
-#: ../auth.c:132 ../auth.c:470
+#: ../auth.c:157 ../auth.c:503
 msgid "Blank passwords are not allowed."
 msgstr ""
 
-#: ../auth.c:153
+#: ../auth.c:178
 msgid "Your password was not accepted."
 msgstr ""
 
-#: ../auth.c:245
+#: ../auth.c:278
 msgid ""
 "This program was unable to connect or stay connected to the Citadel server.  "
 "Please report this problem to your system administrator."
 msgstr ""
 
-#: ../auth.c:253
+#: ../auth.c:286
 msgid "Close window"
 msgstr ""
 
-#: ../auth.c:274 ../mainmenu.c:239
+#: ../auth.c:307 ../mainmenu.c:239
 msgid "Validate new users"
 msgstr ""
 
-#: ../auth.c:325
+#: ../auth.c:358
 #, c-format
 msgid "Current access level: %d (%s)\n"
 msgstr ""
 
-#: ../auth.c:333
+#: ../auth.c:366
 msgid "Select access level for this user:"
 msgstr ""
 
-#: ../auth.c:395 ../mainmenu.c:135
+#: ../auth.c:428 ../mainmenu.c:135
 msgid "Change your password"
 msgstr ""
 
-#: ../auth.c:424
+#: ../auth.c:457
 msgid "Enter new password:"
 msgstr ""
 
-#: ../auth.c:428
+#: ../auth.c:461
 msgid "Enter it again to confirm:"
 msgstr ""
 
-#: ../auth.c:433
+#: ../auth.c:466
 msgid "Change password"
 msgstr ""
 
-#: ../auth.c:435 ../calendar.c:582 ../event.c:385 ../graphics.c:57
+#: ../auth.c:468 ../calendar.c:582 ../event.c:385 ../graphics.c:57
 #: ../iconbar.c:699 ../mainmenu.c:298 ../messages.c:2590 ../messages.c:2693
 #: ../messages.c:2777 ../netconf.c:79 ../netconf.c:139 ../paging.c:56
 #: ../preferences.c:361 ../roomops.c:1162 ../roomops.c:1489 ../roomops.c:1917
@@ -133,11 +137,11 @@ msgstr ""
 msgid "Cancel"
 msgstr ""
 
-#: ../auth.c:451
+#: ../auth.c:484
 msgid "Cancelled.  Password was not changed."
 msgstr ""
 
-#: ../auth.c:462
+#: ../auth.c:495
 msgid "They don't match.  Password was not changed."
 msgstr ""
 
@@ -542,11 +546,11 @@ msgstr ""
 msgid "realloc() error! couldn't get %d bytes: %s"
 msgstr ""
 
-#: ../iconbar.c:97 ../iconbar.c:391
+#: ../iconbar.c:97 ../iconbar.c:381
 msgid "Find out more about Citadel"
 msgstr ""
 
-#: ../iconbar.c:98 ../iconbar.c:392
+#: ../iconbar.c:98 ../iconbar.c:382
 msgid "CITADEL"
 msgstr ""
 
@@ -630,23 +634,24 @@ msgstr ""
 msgid "Administration"
 msgstr ""
 
-#: ../iconbar.c:300 ../iconbar.c:309 ../mainmenu.c:108
+#: ../iconbar.c:299 ../iconbar.c:308 ../iconbar.c:392 ../iconbar.c:401
+#: ../mainmenu.c:108
 msgid "Log off"
 msgstr ""
 
-#: ../iconbar.c:301
+#: ../iconbar.c:300 ../iconbar.c:393
 msgid "Log off now?"
 msgstr ""
 
-#: ../iconbar.c:320
+#: ../iconbar.c:318
 msgid "Customize this menu"
 msgstr ""
 
-#: ../iconbar.c:321
+#: ../iconbar.c:319
 msgid "customize this menu"
 msgstr ""
 
-#: ../iconbar.c:396
+#: ../iconbar.c:386
 msgid "switch to menu"
 msgstr ""
 
@@ -1738,7 +1743,7 @@ msgstr ""
 msgid "Expire by message count"
 msgstr ""
 
-#: ../roomops.c:1541 ../roomops.c:2843
+#: ../roomops.c:1541 ../roomops.c:2880
 msgid "Cancelled.  Changes were not saved."
 msgstr ""
 
index cd1ee061d8bd953bd496fa4004a765fd8f03f8e2..c2692c817f0dc32eed2807197b7d225e961dcacc 100644 (file)
@@ -12,6 +12,8 @@
                <td><input type="text" name="name" maxlength="25"></td></tr>
                <tr><td><?PASSWORD_BOX></td>
                <td><input type="password" name="pass" maxlength="20"></td></tr>
+               <tr><td><?LANGUAGE_BOX></td>
+               <td><?DO_LANGUAGE_BOX></td></tr>
 
        <tr><td align=center colspan=2>
        <input type="submit" name="login_action" value="<?LOGIN_BUTTON>">