#include "webcit.h"
#include "webserver.h"
+#define SEARCH_LANG 20 /* how many langs should we parse? */
#ifdef ENABLE_NLS
/* actual supported locales */
-const char *AvailLang[NUM_LANGS] = {
+const char *AvailLang[] = {
"C",
"en_US",
"de_DE",
"da_DK",
"fr_FR",
"nl_NL",
- "pt_BR"
- "hu_HU"
+ "pt_BR",
+ "hu_HU",
+ ""
};
-const char *AvailLangLoaded[NUM_LANGS];
+const char **AvailLangLoaded;
long nLocalesLoaded = 0;
#ifdef HAVE_USELOCALE
-locale_t wc_locales[NUM_LANGS]; /**< here we keep the parsed stuff */
+locale_t *wc_locales; /**< here we keep the parsed stuff */
#endif
/** Keep information about one locale */
* \brief Create a locale_t for each available language
*/
void initialize_locales(void) {
+ int nLocales;
int i;
char buf[32];
char *language = NULL;
-
+ char *locale;
+
+
+ nLocales = 0;
+ while (!IsEmptyStr(AvailLang[nLocales]))
+ nLocales++;
+
language = getenv("WEBCIT_LANG");
if ((language) && (!IsEmptyStr(language)) && (strcmp(language, "UNLIMITED") != 0)) {
lprintf(9, "Nailing locale to %s\n", language);
}
else language = NULL;
+ AvailLangLoaded = malloc (sizeof(char*) * nLocales);
+ memset(AvailLangLoaded, 0, sizeof(char*) * nLocales);
#ifdef HAVE_USELOCALE
+ wc_locales = malloc (sizeof(locale_t) * nLocales);
+ memset(wc_locales,0, sizeof(locale_t) * nLocales);
/* create default locale */
Empty_Locale = newlocale(LC_ALL_MASK, NULL, NULL);
#endif
- for (i = 0; i < NUM_LANGS; ++i) {
+ for (i = 0; i < nLocales; ++i) {
if ((language != NULL) && (strcmp(AvailLang[i], language) != 0))
continue;
if (i == 0) {
(((i > 0) && (wc_locales[0] != NULL)) ? wc_locales[0] : Empty_Locale)
);
if (wc_locales[nLocalesLoaded] == NULL) {
- lprintf(1, "Error configuring locale for %s: %s\n",
+ lprintf(1, "Error configuring locale for "LOCALEDIR"locale/%s: %s\n",
buf,
strerror(errno)
);
#endif
+#ifdef ENABLE_NLS
+ locale = setlocale(LC_ALL, "");
+
+ lprintf(9, "Message catalog directory: %s\n", bindtextdomain("webcit", LOCALEDIR"/locale"));
+ lprintf(9, "Text domain: %s\n", textdomain("webcit"));
+ lprintf(9, "Text domain Charset: %s\n", bind_textdomain_codeset("webcit","UTF8"));
+
+#endif
}
-void ShutdownLocale(void)
+void
+ServerShutdownModule_GETTEXT
+(void)
{
#ifdef HAVE_USELOCALE
int i;
if (Empty_Locale != wc_locales[i])
freelocale(wc_locales[i]);
}
+ free(wc_locales);
+ free(AvailLangLoaded);
#endif
}
InitModule_GETTEXT
(void)
{
+ initialize_locales();
RegisterNamespace("LANG:SELECT", 0, 0, tmplput_offer_languages, CTX_NONE);
}
}
-
+extern char **AvailLang;
int GetLocalePrefs(void)
{
+ int nLocales;
StrBuf *Buf;
char buf[SIZ];
char dialog_result[PATH_MAX];
int offs = 0;
+ nLocales = 0;
+ while (!IsEmptyStr(AvailLang[nLocales]))
+ nLocales++;
+
Buf = NewStrBuf();
StrBufAppendBufPlain(Buf, HKEY("Select the locale webcit should use : \n"), 0);
StrBufAppendBufPlain(Buf, HKEY(" 0 Let the user select it at the login prompt (default)\n"), 0);
offs ++;
#endif
- for (i = 0; i < NUM_LANGS; i++) {
+ for (i = 0; i < nLocales; i++) {
StrBufAppendPrintf(Buf, " %ld: %s\n", i + offs, AvailLang[i]);
}
+++ /dev/null
-#ifdef ENABLE_NLS
-void initialize_locales(void);
-void ShutdownLocale(void);
-
-#define NUM_LANGS 10 /* how many different locales do we know? */
-#define SEARCH_LANG 20 /* how many langs should we parse? */
-
-/* actual supported locales */
-extern const char *AvailLang[NUM_LANGS];
-#else
-#define NUM_LANGS 1 /* how many different locales do we know? */
-#endif
-void TmplGettext(StrBuf *Target, WCTemplputParams *TP);
-void offer_languages(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType);
-void set_selected_language(const char *);
-void go_selected_language(void);
-void stop_selected_language(void);
char *pidfile = NULL;
char *hdir;
const char *basedir = NULL;
-#ifdef ENABLE_NLS
- char *locale = NULL;
- char *mo = NULL;
-#endif /* ENABLE_NLS */
char uds_listen_path[PATH_MAX]; /* listen on a unix domain socket? */
const char *I18nDumpFile = NULL;
/* initialize the International Bright Young Thing */
-#ifdef ENABLE_NLS
- initialize_locales();
-
-
- locale = setlocale(LC_ALL, "");
-
- mo = malloc(strlen(webcitdir) + 20);
- lprintf(9, "Message catalog directory: %s\n", bindtextdomain("webcit", LOCALEDIR"/locale"));
- free(mo);
- lprintf(9, "Text domain: %s\n", textdomain("webcit"));
- lprintf(9, "Text domain Charset: %s\n", bind_textdomain_codeset("webcit","UTF8"));
-#endif
initialise_modules();
initialize_viewdefs();
icalmemory_free_ring ();
ShutDownLibCitadel ();
shutdown_modules ();
-#ifdef ENABLE_NLS
- ShutdownLocale();
-#endif
#ifdef HAVE_OPENSSL
if (is_https) {
shutdown_ssl();