summaryrefslogtreecommitdiff
path: root/source3/web/cgi.c
diff options
context:
space:
mode:
authorMotonobu Takahashi <monyo@samba.org>2001-09-24 15:55:09 +0000
committerMotonobu Takahashi <monyo@samba.org>2001-09-24 15:55:09 +0000
commit96db4b1ba3a48f50b80b2cfbf0b940e073b7843c (patch)
treebd8d1c25af214250053a84b71b668e81bef7ef5d /source3/web/cgi.c
parent63dba7abe04c1d33bbfa5e921e4aa967dc3966c3 (diff)
downloadsamba-96db4b1ba3a48f50b80b2cfbf0b940e073b7843c.tar.gz
samba-96db4b1ba3a48f50b80b2cfbf0b940e073b7843c.tar.bz2
samba-96db4b1ba3a48f50b80b2cfbf0b940e073b7843c.zip
Added SWAT i18n feature:
TO enable configure with --with-i18n-swat to support this gettext is integrated and a new directories name "po" and "intl" are created. now these languages are supported: en - English (default) ja - Japanese po - Polish tr - Turkish To add your language, to create ${your_language}.po by translating source/po/en.po into your language is needed. some of html and image files of various language version are not included yet, though message catalogue files are installed. you need to copy files manually under ${swatdir}/lang/$ln/{help,images,included,using_samba} And also added a option to intall manual pages: of various lang version To enable configure with --with-manlangs but manual pages themself are not included yet. (This used to be commit 486b79a6fc4ba20a751aab544bd0f7ccff2b3d19)
Diffstat (limited to 'source3/web/cgi.c')
-rw-r--r--source3/web/cgi.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/source3/web/cgi.c b/source3/web/cgi.c
index 939b8f94cd..d2b30c49e9 100644
--- a/source3/web/cgi.c
+++ b/source3/web/cgi.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "smb.h"
+#include "webintl.h"
#define MAX_VARIABLES 10000
@@ -447,6 +448,7 @@ static void cgi_download(char *file)
char buf[1024];
int fd, l, i;
char *p;
+ int nLangDesc;
/* sanitise the filename */
for (i=0;file[i];i++) {
@@ -460,7 +462,11 @@ static void cgi_download(char *file)
cgi_setup_error("404 File Not Found","",
"The requested file was not found");
}
+#if I18N_SWAT
+ fd = sys_open(ln_get_pref_file(file, &st, &nLangDesc),O_RDONLY,0);
+#else
fd = sys_open(file,O_RDONLY,0);
+#endif
if (fd == -1) {
cgi_setup_error("404 File Not Found","",
"The requested file was not found");
@@ -478,7 +484,10 @@ static void cgi_download(char *file)
}
}
printf("Expires: %s\r\n", http_timestring(time(NULL)+EXPIRY_TIME));
-
+#if I18N_SWAT
+ if(ln_get_lang(nLangDesc))
+ printf("Content-Language: %s\r\n", ln_get_lang(nLangDesc));
+#endif
printf("Content-Length: %d\r\n\r\n", (int)st.st_size);
while ((l=read(fd,buf,sizeof(buf)))>0) {
fwrite(buf, 1, l, stdout);
@@ -509,6 +518,11 @@ void cgi_setup(char *rootdir, int auth_required)
/* Handle the possability we might be running as non-root */
sec_init();
+#if I18N_SWAT
+ if(getenv("HTTP_ACCEPT_LANGUAGE")) /* if running as a cgi program */
+ ln_negotiate_language(getenv("HTTP_ACCEPT_LANGUAGE"));
+#endif
+
/* maybe we are running under a web server */
if (getenv("CONTENT_LENGTH") || getenv("REQUEST_METHOD")) {
if (auth_required) {
@@ -543,6 +557,10 @@ void cgi_setup(char *rootdir, int auth_required)
authenticated = cgi_handle_authorization(&line[15]);
} else if (strncasecmp(line,"Content-Length: ", 16)==0) {
content_length = atoi(&line[16]);
+#if I18N_SWAT
+ } else if (strncasecmp(line,"Accept-Language: ", 17)==0) {
+ ln_negotiate_language(&line[17]);
+#endif
}
/* ignore all other requests! */
}