* add Hungarian translation by Czakó Krisztián
[citadel.git] / webcit / gettext.c
index f3472b3617779f02e2826fb35dd62b38985b05a0..990ef23d034b5042fde732076257e757839825d0 100644 (file)
@@ -18,6 +18,7 @@ const char *AvailLang[NUM_LANGS] = {
        "fr_FR",
        "nl_NL",
        "pt_BR"
+       "hu_HU"
 };
 
 const char *AvailLangLoaded[NUM_LANGS];
@@ -47,7 +48,7 @@ typedef struct _lang_pref{
  * \param LocaleString the string from the browser http headers
  */
 
-void httplang_to_locale(StrBuf *LocaleString)
+void httplang_to_locale(StrBuf *LocaleString, wcsession *sess)
 {
        LangStruct wanted_locales[SEARCH_LANG];
        LangStruct *ls;
@@ -61,7 +62,7 @@ void httplang_to_locale(StrBuf *LocaleString)
        int nParts;
        StrBuf *Buf = NULL;
        StrBuf *SBuf = NULL;
-       
+
        nParts=StrBufNum_tokens(LocaleString,',');
        for (i=0; ((i<nParts)&&(i<SEARCH_LANG)); i++)
         {
@@ -152,7 +153,7 @@ void httplang_to_locale(StrBuf *LocaleString)
                /** fall back to C */
                nBest=0;
        }
-       WC->selected_language=nBest;
+       sess->selected_language=nBest;
        lprintf(9, "language found: %s\n", AvailLangLoaded[WC->selected_language]);
        FreeStrBuf(&Buf);
        FreeStrBuf(&SBuf);
@@ -395,12 +396,15 @@ SessionNewModule_GETTEXT
 (wcsession *sess)
 {
 #ifdef ENABLE_NLS
-       void *vLine;
-       
-       if (GetHash(WC->headers, HKEY("ACCEPT-LANGUAGE"), &vLine) && 
-           (vLine != NULL)) {
-               StrBuf *accept_language = (StrBuf*) vLine;
-               httplang_to_locale(accept_language);
+       OneHttpHeader *vLine = NULL;
+
+       if (    (sess->Hdr->HTTPHeaders != NULL)
+               && GetHash(sess->Hdr->HTTPHeaders, HKEY("ACCEPT-LANGUAGE"), (void *)&vLine)
+               && (vLine != NULL)
+               && (vLine->Val != NULL)
+       ) {
+               StrBuf *accept_language = vLine->Val;
+               httplang_to_locale(accept_language, sess);
        }
 #endif
 }