add changes from ubuntu launchpad
[citadel.git] / webcit / gettext.c
index 432e0ff7428938fa9b74c16cec39206d516c1f33..f1b2f8a2713b109aa2912da3ddfd37e9c34fd179 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996-2010 by the citadel.org team
+ * Copyright (c) 1996-2011 by the citadel.org team
  *
  * This program is open source software.  You can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -33,12 +33,18 @@ const char *AvailLang[] = {
        "en_GB",
        "es_ES",
        "et_EE",
+       "fi_FI",
        "fr_FR",
        "hu_HU",
        "it_IT",
        "nl_NL",
        "pt_BR",
        "ru_RU",
+       "zh_CN",
+       "he_IL",
+       "kk_KK",
+       "ro_RO",
+       "sl_SL",
        ""
 };
 
@@ -217,7 +223,7 @@ void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
                return;
        }
 
-       wc_printf("<select name=\"language\" id=\"lname\" size=\"1\" onChange=\"window.location.reload();\">\n");
+       wc_printf("<select name=\"language\" id=\"lname\" size=\"1\" onChange=\"switch_to_lang($('lname').value);\">\n");
 
        for (i=0; i < nLocalesLoaded; ++i) {
 #ifndef HAVE_USELOCALE
@@ -286,8 +292,6 @@ void initialize_locales(void) {
        int i;
        char buf[32];
        char *language = NULL;
-       char *locale;
-
 
        nLocales = 0; 
        while (!IsEmptyStr(AvailLang[nLocales]))
@@ -367,7 +371,7 @@ void initialize_locales(void) {
        }
 
 #ifdef ENABLE_NLS
-       locale = setlocale(LC_ALL, "");
+       /*locale = */setlocale(LC_ALL, "");
 
        syslog(9, "Message catalog directory: %s\n", bindtextdomain("webcit", LOCALEDIR"/locale"));
        syslog(9, "Text domain: %s\n", textdomain("webcit"));
@@ -448,6 +452,7 @@ void Header_HandleAcceptLanguage(StrBuf *Line, ParsedHttpHdrs *hdr)
        hdr->HR.browser_language = Line;
 }
 
+
 void 
 InitModule_GETTEXT
 (void)
@@ -467,8 +472,10 @@ SessionNewModule_GETTEXT
 (wcsession *sess)
 {
 #ifdef ENABLE_NLS
-       if (!sess->Hdr->HR.Static && 
-           (sess->Hdr->HR.browser_language != NULL)) {
+       if (    (sess != NULL)
+               && (!sess->Hdr->HR.Static)
+               && (sess->Hdr->HR.browser_language != NULL)
+       ) {
                httplang_to_locale(sess->Hdr->HR.browser_language, sess);
        }
 #endif