projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
898bab0
)
Revert "Remove ENABLE_NLS definition. Either we HAVE_USELOCALE or we don't translate...
author
Art Cancro
<ajc@uncensored.citadel.org>
Wed, 22 Feb 2012 23:22:25 +0000
(18:22 -0500)
committer
Art Cancro
<ajc@uncensored.citadel.org>
Wed, 22 Feb 2012 23:22:25 +0000
(18:22 -0500)
This reverts commit
898bab06ba7d6cf04a9b5e41bfcc6319ff3bb8de
.
webcit/configure.ac
patch
|
blob
|
history
webcit/fmt_date.c
patch
|
blob
|
history
webcit/gettext.c
patch
|
blob
|
history
webcit/setup.c
patch
|
blob
|
history
webcit/webcit.h
patch
|
blob
|
history
diff --git
a/webcit/configure.ac
b/webcit/configure.ac
index 4ce75792be46007f1b688ecb4d54d1d261349926..6f3a7bc775ebfd4a6901e17da0984ff2a96a86c4 100644
(file)
--- a/
webcit/configure.ac
+++ b/
webcit/configure.ac
@@
-400,6
+400,11
@@
AC_ARG_WITH(ssldir,
)
AC_DEFINE_UNQUOTED(SSL_DIR, "$ssl_dir", [were should we put our keys?])
)
AC_DEFINE_UNQUOTED(SSL_DIR, "$ssl_dir", [were should we put our keys?])
+
+
+
+AC_CHECK_FUNCS(strftime_l uselocale gettext)
+
if test "$ok_nls" != "no"; then
AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
ok_nls=$ok_xgettext
if test "$ok_nls" != "no"; then
AC_CHECK_PROG(ok_xgettext, xgettext, yes, no)
ok_nls=$ok_xgettext
@@
-416,8
+421,11
@@
if test "$ok_nls" != "no"; then
fi
if test "$ok_nls" != "no"; then
fi
if test "$ok_nls" != "no"; then
- AC_CHECK_FUNCS(strftime_l uselocale gettext)
+ AC_MSG_RESULT(WebCit will be built with national language support.)
+ AC_DEFINE(ENABLE_NLS, [], [whether we have NLS support])
PROG_SUBDIRS="$PROG_SUBDIRS po/webcit/"
PROG_SUBDIRS="$PROG_SUBDIRS po/webcit/"
+else
+ AC_MSG_RESULT(WebCit will be built without national language support.)
fi
AC_SUBST(SETUP_LIBS)
fi
AC_SUBST(SETUP_LIBS)
diff --git
a/webcit/fmt_date.c
b/webcit/fmt_date.c
index 7979ecf585efec511d573c8c63ee795739b035fe..15e5673ca25756813f6529f6fff6d6aa4e21bb5e 100644
(file)
--- a/
webcit/fmt_date.c
+++ b/
webcit/fmt_date.c
@@
-40,6
+40,7
@@
typedef unsigned char byte;
size_t wc_strftime(char *s, size_t max, const char *format, const struct tm *tm)
{
size_t wc_strftime(char *s, size_t max, const char *format, const struct tm *tm)
{
+#ifdef ENABLE_NLS
#ifdef HAVE_USELOCALE
if (wc_locales[WC->selected_language] == NULL) {
return strftime(s, max, format, tm);
#ifdef HAVE_USELOCALE
if (wc_locales[WC->selected_language] == NULL) {
return strftime(s, max, format, tm);
@@
-50,6
+51,9
@@
size_t wc_strftime(char *s, size_t max, const char *format, const struct tm *tm)
#else
return strftime(s, max, format, tm);
#endif
#else
return strftime(s, max, format, tm);
#endif
+#else
+ return strftime(s, max, format, tm);
+#endif
}
}
diff --git
a/webcit/gettext.c
b/webcit/gettext.c
index 71ede4e0ad2083f58f66a6ae57307d78f6f34758..4df641a28e7ce01f4eb1a8fda82878ae59140fa1 100644
(file)
--- a/
webcit/gettext.c
+++ b/
webcit/gettext.c
@@
-14,7
+14,7
@@
#include "webserver.h"
#define SEARCH_LANG 20 /* how many langs should we parse? */
#include "webserver.h"
#define SEARCH_LANG 20 /* how many langs should we parse? */
-#ifdef
HAVE_USELOCALE
+#ifdef
ENABLE_NLS
/* actual supported locales */
const char *AvailLang[] = {
"C",
/* actual supported locales */
const char *AvailLang[] = {
"C",
@@
-46,7
+46,9
@@
const char *AvailLang[] = {
const char **AvailLangLoaded;
long nLocalesLoaded = 0;
const char **AvailLangLoaded;
long nLocalesLoaded = 0;
+#ifdef HAVE_USELOCALE
locale_t *wc_locales; /* here we keep the parsed stuff */
locale_t *wc_locales; /* here we keep the parsed stuff */
+#endif
/* Keep information about one locale */
typedef struct _lang_pref{
/* Keep information about one locale */
typedef struct _lang_pref{
@@
-207,6
+209,7
@@
void httplang_to_locale(StrBuf *LocaleString, wcsession *sess)
*/
void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
{
*/
void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
{
+#ifdef HAVE_USELOCALE
int i;
wc_printf("<select name=\"language\" id=\"lname\" size=\"1\" onChange=\"switch_to_lang($('lname').value);\">\n");
int i;
wc_printf("<select name=\"language\" id=\"lname\" size=\"1\" onChange=\"switch_to_lang($('lname').value);\">\n");
@@
-220,12
+223,16
@@
void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
}
wc_printf("</select>\n");
}
wc_printf("</select>\n");
+#else
+ wc_printf("%s", (getenv("LANG") ? getenv("LANG") : "C"));
+#endif
}
/*
* Set the selected language for this session.
*/
void set_selected_language(const char *lang) {
}
/*
* Set the selected language for this session.
*/
void set_selected_language(const char *lang) {
+#ifdef HAVE_USELOCALE
int i;
for (i = 0; i<nLocalesLoaded; ++i) {
if (!strcasecmp(lang, AvailLangLoaded[i])) {
int i;
for (i = 0; i<nLocalesLoaded; ++i) {
if (!strcasecmp(lang, AvailLangLoaded[i])) {
@@
-233,24
+240,34
@@
void set_selected_language(const char *lang) {
break;
}
}
break;
}
}
+#endif
}
/*
* Activate the selected language for this session.
*/
void go_selected_language(void) {
}
/*
* Activate the selected language for this session.
*/
void go_selected_language(void) {
+#ifdef HAVE_USELOCALE
wcsession *WCC = WC;
if (WCC->selected_language < 0) return;
uselocale(wc_locales[WCC->selected_language]); /* switch locales */
textdomain(textdomain(NULL)); /* clear the cache */
wcsession *WCC = WC;
if (WCC->selected_language < 0) return;
uselocale(wc_locales[WCC->selected_language]); /* switch locales */
textdomain(textdomain(NULL)); /* clear the cache */
+#else
+ char *language;
+
+ language = getenv("LANG");
+ setlocale(LC_MESSAGES, language);
+#endif
}
/*
* Deactivate the selected language for this session.
*/
void stop_selected_language(void) {
}
/*
* Deactivate the selected language for this session.
*/
void stop_selected_language(void) {
+#ifdef HAVE_USELOCALE
uselocale(LC_GLOBAL_LOCALE); /* switch locales */
textdomain(textdomain(NULL)); /* clear the cache */
uselocale(LC_GLOBAL_LOCALE); /* switch locales */
textdomain(textdomain(NULL)); /* clear the cache */
+#endif
}
}
@@
-262,10
+279,12
@@
void initialize_locales(void) {
int i;
char *language = NULL;
int i;
char *language = NULL;
+#ifdef ENABLE_NLS
setlocale(LC_ALL, "");
syslog(9, "Text domain: %s", textdomain("webcit"));
syslog(9, "Message catalog directory: %s", bindtextdomain(textdomain(NULL), LOCALEDIR"/locale"));
syslog(9, "Text domain Charset: %s", bind_textdomain_codeset("webcit","UTF8"));
setlocale(LC_ALL, "");
syslog(9, "Text domain: %s", textdomain("webcit"));
syslog(9, "Message catalog directory: %s", bindtextdomain(textdomain(NULL), LOCALEDIR"/locale"));
syslog(9, "Text domain Charset: %s", bind_textdomain_codeset("webcit","UTF8"));
+#endif
nLocales = 0;
while (!IsEmptyStr(AvailLang[nLocales]))
nLocales = 0;
while (!IsEmptyStr(AvailLang[nLocales]))
@@
-279,11
+298,14
@@
void initialize_locales(void) {
AvailLangLoaded = malloc (sizeof(char*) * nLocales);
memset(AvailLangLoaded, 0, sizeof(char*) * nLocales);
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);
wc_locales[0] = newlocale(LC_ALL_MASK, NULL, NULL);
wc_locales = malloc (sizeof(locale_t) * nLocales);
memset(wc_locales,0, sizeof(locale_t) * nLocales);
wc_locales[0] = newlocale(LC_ALL_MASK, NULL, NULL);
+#endif
for (i = 1; i < nLocales; ++i) {
for (i = 1; i < nLocales; ++i) {
+#ifdef HAVE_USELOCALE
wc_locales[nLocalesLoaded] = newlocale(
(LC_MESSAGES_MASK|LC_TIME_MASK),
AvailLang[i],
wc_locales[nLocalesLoaded] = newlocale(
(LC_MESSAGES_MASK|LC_TIME_MASK),
AvailLang[i],
@@
-302,11
+324,26
@@
void initialize_locales(void) {
AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
nLocalesLoaded++;
}
AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
nLocalesLoaded++;
}
+#else
+ if ((language != NULL) && (strcmp(language, AvailLang[i]) == 0)) {
+ setenv("LANG", AvailLang[i], 1);
+ AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
+ setlocale(LC_MESSAGES, AvailLang[i]);
+ nLocalesLoaded++;
+ }
+ else if (nLocalesLoaded == 0) {
+ setenv("LANG", AvailLang[i], 1);
+ AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
+ nLocalesLoaded++;
+ }
+#endif
}
if ((language != NULL) && (nLocalesLoaded == 0)) {
syslog(1, "Your selected locale [%s] isn't available on your system. falling back to C", language);
}
if ((language != NULL) && (nLocalesLoaded == 0)) {
syslog(1, "Your selected locale [%s] isn't available on your system. falling back to C", language);
+#ifndef HAVE_USELOCALE
setlocale(LC_MESSAGES, AvailLang[0]);
setenv("LANG", AvailLang[0], 1);
setlocale(LC_MESSAGES, AvailLang[0]);
setenv("LANG", AvailLang[0], 1);
+#endif
AvailLangLoaded[0] = AvailLang[0];
nLocalesLoaded = 1;
}
AvailLangLoaded[0] = AvailLang[0];
nLocalesLoaded = 1;
}
@@
-317,15
+354,17
@@
void
ServerShutdownModule_GETTEXT
(void)
{
ServerShutdownModule_GETTEXT
(void)
{
+#ifdef HAVE_USELOCALE
int i;
for (i = 0; i < nLocalesLoaded; ++i) {
freelocale(wc_locales[i]);
}
free(wc_locales);
int i;
for (i = 0; i < nLocalesLoaded; ++i) {
freelocale(wc_locales[i]);
}
free(wc_locales);
+#endif
free(AvailLangLoaded);
}
free(AvailLangLoaded);
}
-#else /*
HAVE_USELOCALE
*/
+#else /*
ENABLE_NLS
*/
const char *AvailLang[] = {
"C",
""
const char *AvailLang[] = {
"C",
""
@@
-349,24
+388,10
@@
void go_selected_language(void) {
void stop_selected_language(void) {
}
void stop_selected_language(void) {
}
-/* dummy for non NLS enabled systems */
void initialize_locales(void) {
}
void initialize_locales(void) {
}
-/* dummy for non NLS enabled systems */
-void
-ServerShutdownModule_GETTEXT
-(void)
-{
-}
-
-
-#endif /* HAVE_USELOCALE */
-
-
-
-
-
+#endif /* ENABLE_NLS */
void TmplGettext(StrBuf *Target, WCTemplputParams *TP)
void TmplGettext(StrBuf *Target, WCTemplputParams *TP)
@@
-380,11
+405,15
@@
void TmplGettext(StrBuf *Target, WCTemplputParams *TP)
* This function returns a static string, so don't do anything stupid please.
*/
const char *get_selected_language(void) {
* This function returns a static string, so don't do anything stupid please.
*/
const char *get_selected_language(void) {
+#ifdef ENABLE_NLS
#ifdef HAVE_USELOCALE
return AvailLang[WC->selected_language];
#else
return "en";
#endif
#ifdef HAVE_USELOCALE
return AvailLang[WC->selected_language];
#else
return "en";
#endif
+#else
+ return "en";
+#endif
}
}
@@
-412,7
+441,7
@@
void
SessionNewModule_GETTEXT
(wcsession *sess)
{
SessionNewModule_GETTEXT
(wcsession *sess)
{
-#ifdef
HAVE_USELOCALE
+#ifdef
ENABLE_NLS
if ( (sess != NULL)
&& (!sess->Hdr->HR.Static)
&& (sess->Hdr->HR.browser_language != NULL)
if ( (sess != NULL)
&& (!sess->Hdr->HR.Static)
&& (sess->Hdr->HR.browser_language != NULL)
@@
-426,7
+455,7
@@
void
SessionAttachModule_GETTEXT
(wcsession *sess)
{
SessionAttachModule_GETTEXT
(wcsession *sess)
{
-#ifdef
HAVE_USELOCALE
+#ifdef
ENABLE_NLS
go_selected_language(); /* set locale */
#endif
}
go_selected_language(); /* set locale */
#endif
}
@@
-435,7
+464,7
@@
void
SessionDestroyModule_GETTEXT
(wcsession *sess)
{
SessionDestroyModule_GETTEXT
(wcsession *sess)
{
-#ifdef
HAVE_USELOCALE
+#ifdef
ENABLE_NLS
stop_selected_language(); /* unset locale */
#endif
}
stop_selected_language(); /* unset locale */
#endif
}
diff --git
a/webcit/setup.c
b/webcit/setup.c
index f4653dcac0563304ce5d32be7b594e13acce5627..cfb215eb73f8a275349fdf5dfa229d380174d105 100644
(file)
--- a/
webcit/setup.c
+++ b/
webcit/setup.c
@@
-31,10
+31,15
@@
void RegisterNS(const char *NSName, long len,
void RegisterHeaderHandler(const char *Name, long Len, Header_Evaluator F){}
pthread_key_t MyConKey;
void RegisterHeaderHandler(const char *Name, long Len, Header_Evaluator F){}
pthread_key_t MyConKey;
+#ifdef ENABLE_NLS
+
#ifdef HAVE_USELOCALE
int localeoffset = 1;
#ifdef HAVE_USELOCALE
int localeoffset = 1;
+#else
+int localeoffset = 0;
#endif
#endif
+#endif
/*
* Delete an entry from /etc/inittab
*/
/*
* Delete an entry from /etc/inittab
*/
@@
-406,7
+411,7
@@
void progress(char *text, long int curr, long int cmax)
*/
void install_init_scripts(void)
{
*/
void install_init_scripts(void)
{
-#ifdef
HAVE_USELOCALE
+#ifdef
ENABLE_NLS
int localechoice;
#endif
char question[1024];
int localechoice;
#endif
char question[1024];
@@
-441,8
+446,10
@@
void install_init_scripts(void)
return;
return;
-#ifdef HAVE_USELOCALE
+#ifdef ENABLE_NLS
+
localechoice = GetLocalePrefs();
localechoice = GetLocalePrefs();
+
#endif
/* Defaults */
sprintf(http_port, "2000");
#endif
/* Defaults */
sprintf(http_port, "2000");
@@
-548,18
+555,22
@@
void install_init_scripts(void)
fprintf(fp, "CTDL_HOSTNAME=%s\n", hostname);
fprintf(fp, "CTDL_PORTNAME=%s\n", portname);
fprintf(fp, "CTDL_HOSTNAME=%s\n", hostname);
fprintf(fp, "CTDL_PORTNAME=%s\n", portname);
-#ifdef HAVE_USELOCALE
+#ifdef ENABLE_NLS
+
if (localechoice == 0) {
if (localechoice == 0) {
+#ifdef HAVE_USELOCALE
+ fprintf(fp, "unset LANG\n");
+#else
+ fprintf(fp, "export WEBCIT_LANG=c\n");
+#endif
+ }
+ else {
fprintf(fp, "export WEBCIT_LANG=%s\n", AvailLang[localechoice - localeoffset]);
fprintf(fp, "export WEBCIT_LANG=%s\n", AvailLang[localechoice - localeoffset]);
+
}
#else
fprintf(fp, "# your system doesn't support locales\n");
#endif
}
#else
fprintf(fp, "# your system doesn't support locales\n");
#endif
-
-
-
-
-
fprintf(fp, "\n"
"\n"
"case \"$1\" in\n"
fprintf(fp, "\n"
"\n"
"case \"$1\" in\n"
diff --git
a/webcit/webcit.h
b/webcit/webcit.h
index 67131a5eb3345459997438163531d0ecc89f33b3..e713e75bbfb4b0bc62db459339fd082678bdac01 100644
(file)
--- a/
webcit/webcit.h
+++ b/
webcit/webcit.h
@@
-53,7
+53,7
@@
#include <iconv.h>
#endif
#include <iconv.h>
#endif
-#ifdef
HAVE_USELOCALE
+#ifdef
ENABLE_NLS
#ifdef HAVE_XLOCALE_H
#include <xlocale.h>
#endif
#ifdef HAVE_XLOCALE_H
#include <xlocale.h>
#endif