]> code.citadel.org Git - citadel.git/blobdiff - webcit/gettext.c
* Added a null pointer check to the 'language' variable to prevent crash
[citadel.git] / webcit / gettext.c
index 241fb9eedd6924d4d94044a01ab3337347ff833c..917ee4bd30508f8159482cde961798279c4bdda3 100644 (file)
@@ -6,10 +6,6 @@
 #include "webserver.h"
 
 #ifdef ENABLE_NLS
-
-#define NUM_LANGS 10           /* how many different locales do we know? */
-#define SEARCH_LANG 20         /* how many langs should we parse? */
-
 /* actual supported locales */
 const char *AvailLang[NUM_LANGS] = {
        "C",
@@ -167,7 +163,8 @@ void httplang_to_locale(StrBuf *LocaleString)
  * depending on the browser locale change the sequence of the 
  * language chooser.
  */
-void tmplput_offer_languages(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) {
+void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
+{
        int i;
 #ifndef HAVE_USELOCALE
        char *Lang = getenv("LANG");
@@ -237,14 +234,14 @@ void stop_selected_language(void) {
 
 void preset_locale(void)
 {
-#ifndef HAVE_USELOCALE
 #ifdef HAVE_GETTEXT
        char *language;
        
-       lprintf(9, "Nailing locale to %s\n", getenv("LANG"));
-       language = getenv("LANG");
-       setlocale(LC_MESSAGES, language);
-#endif
+       language = getenv("WEBCIT_LANG");
+       if ((language) && (!IsEmptyStr(language)) && (strcmp(language, "UNLIMITED") != 0)) {
+               lprintf(9, "Nailing locale to %s\n", language);
+               setlocale(LC_MESSAGES, language);
+       }
 #endif
 }
 
@@ -305,8 +302,12 @@ void ShutdownLocale(void)
 }
 
 #else  /* ENABLE_NLS */
+const char *AvailLang[NUM_LANGS] = {
+       "C"};
+
 /** \brief dummy for non NLS enabled systems */
-void tmplput_offer_languages(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) {
+void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
+{
        wprintf("English (US)");
 }
 
@@ -328,9 +329,9 @@ void preset_locale(void)
 #endif /* ENABLE_NLS */
 
 
-void TmplGettext(StrBuf *Target, int nTokens, WCTemplateToken *Tokens)
+void TmplGettext(StrBuf *Target, WCTemplputParams *TP)
 {
-       StrBufAppendBufPlain(Target, _(Tokens->Params[0]->Start), -1, 0);
+       StrBufAppendBufPlain(Target, _(TP->Tokens->Params[0]->Start), -1, 0);
 }