*/
/**
* \defgroup LocaleHeaderParser Parse the browser http locale headers and set the NLS stuff.
+ * \ingroup WebcitHttpServer
*/
/*@{*/
-/** we need _GNU_SOURCE for various functions arround the NLS-Stuff */
-#define _GNU_SOURCE
#include "webcit.h"
#include "webserver.h"
#ifdef ENABLE_NLS
-#define NUM_LANGS 4 /**< how many different locales do we know? */
+#define NUM_LANGS 5 /**< how many different locales do we know? */
#define SEARCH_LANG 20 /**< how many langs should we parse? */
/** actual supported locales */
"C",
"en_US",
"de_DE",
- "it_IT"
+ "it_IT",
+ "en_GB"
};
locale_t wc_locales[NUM_LANGS]; /**< here we keep the parsed stuff */
int nBest;
int nParts;
char *search = (char *) malloc(len);
- // locale_t my_Locale;
- // locale_t my_Empty_Locale;
memcpy(search, LocaleString, len);
search[len] = '\0';
nBest=0;
WC->selected_language=nBest;
lprintf(9, "language found: %s\n", AvailLang[WC->selected_language]);
- // set_selected_language(selected_locale);
+ if (search != NULL) {
+ free(search);
+ }
}
/* TODO: we skip the language weightening so far. */
for (i = 0; i < NUM_LANGS; ++i) {
sprintf(buf, "%s.UTF8", AvailLang[i]);
- wc_locales[i] = newlocale(LC_MESSAGES_MASK /* |LC_TIME_MASK FIXME */ ,
+ wc_locales[i] = newlocale(
+ (LC_MESSAGES_MASK|LC_TIME_MASK),
buf,
Empty_Locale
);
+ if (wc_locales[i] == NULL) {
+ lprintf(1, "Error configuring locale for %s: %s\n",
+ buf,
+ strerror(errno)
+ );
+ }
+ else {
+ lprintf(3, "Configured available locale: %s\n", buf);
+ }
}
}