#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",
int nBest;
int nParts;
StrBuf *Buf = NULL;
- StrBuf *SBuf;
+ StrBuf *SBuf = NULL;
nParts=StrBufNum_tokens(LocaleString,',');
for (i=0; ((i<nParts)&&(i<SEARCH_LANG)); i++)
FreeStrBuf(&SBuf);
}
-/* TODO: we skip the language weighting so far. */
-/* Accept-Language: 'de-de,en-us;q=0.7,en;q=0.3' */
-/* Accept-Language: de,en-ph;q=0.8,en-us;q=0.5,de-at;q=0.3 */
-//void httplang_to_locale(char *LocaleString)
-//{
-// char selected_locale[16];
-// int i, j;
-// char lang[64];
-// int num_accept = 0;
-//
-// lprintf(9, "languageAccept: %s\n", LocaleString);
-//
-// strcpy(selected_locale, "C");
-// num_accept = num_tokens(LocaleString, ',');
-//
-// for (i=num_accept-1; i>=0; --i) {
-// extract_token(lang, LocaleString, i, ',', sizeof lang);
-//
-// /* Strip out the weights; we don't use them. Also convert
-// * hyphens to underscores.
-// */
-// for (j=0; j<strlen(lang); ++j) {
-// if (lang[j] == '-') lang[j] = '_';
-// if (lang[j] == ';') lang[j] = 0;
-// }
-//
-// for (j=0; j<NUM_LANGS; ++j) {
-// if (!strncasecmp(lang, AvailLang[j], strlen(lang))) {
-// strcpy(selected_locale, AvailLang[j]);
-// }
-// }
-// }
-//
-// lprintf(9, "language found: %s\n", selected_locale);
-// set_selected_language(selected_locale);
-//}
-
-
/**
* \brief show the language chooser on the login dialog
* 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");
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
}
for (i = 0; i < NUM_LANGS; ++i) {
if (i == 0) {
- sprintf(buf, "%s", AvailLang[i]); // locale 0 (C) is ascii, not utf-8
+ sprintf(buf, "%s", AvailLang[i]); /* locale 0 (C) is ascii, not utf-8 */
}
else {
sprintf(buf, "%s.UTF8", AvailLang[i]);
}
#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)");
}
#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);
}