Revert "Simplified tmplput_offer_languages() behavior on non-locale systems"
authorArt Cancro <ajc@uncensored.citadel.org>
Sun, 26 Feb 2012 20:15:44 +0000 (15:15 -0500)
committerArt Cancro <ajc@uncensored.citadel.org>
Sun, 26 Feb 2012 20:15:44 +0000 (15:15 -0500)
This reverts commit 58df800218902d07dcf3b81a28c31354fb1025d2.

webcit/gettext.c

index 4df641a28e7ce01f4eb1a8fda82878ae59140fa1..25474e810c5b8f68eb2f521cdc90de0be6dbb3ad 100644 (file)
@@ -209,12 +209,25 @@ void httplang_to_locale(StrBuf *LocaleString, wcsession *sess)
  */
 void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
 {
-#ifdef HAVE_USELOCALE
        int i;
+#ifndef HAVE_USELOCALE
+       char *Lang = getenv("LANG");
+       
+       if (Lang == NULL)
+               Lang = "C";
+#endif
+
+       if (nLocalesLoaded == 1) {
+               wc_printf("<p>%s</p>", AvailLangLoaded[0]);
+               return;
+       }
 
        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
+               if (strcmp(AvailLangLoaded[i], Lang) == 0)
+#endif
                wc_printf("<option %s value=%s>%s</option>\n",
                        ((WC->selected_language == i) ? "selected" : ""),
                        AvailLangLoaded[i],
@@ -223,9 +236,6 @@ void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
        }
 
        wc_printf("</select>\n");
-#else
-       wc_printf("%s", (getenv("LANG") ? getenv("LANG") : "C"));
-#endif
 }
 
 /*