+ * Copyright (c) 1996-2012 by the citadel.org team
+ *
+ * This program is open source software. You can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
-/** Keep information about one locale */
-typedef struct _lang_pref{
- char lang[16]; /**< the language locale string */
- char region[16]; /**< the region locale string */
- long priority; /**< which priority does it have */
- int availability; /**< do we know it? */
- int selectedlang; /**< is this the selected language? */
+/* Keep information about one locale */
+typedef struct _lang_pref {
+ char lang[16]; /* the language locale string */
+ char region[16]; /* the region locale string */
+ long priority; /* which priority does it have */
+ int availability; /* do we know it? */
+ int selectedlang; /* is this the selected language? */
-/* \brief parse browser locale header
- * seems as most browsers just do a one after coma value even if more than 10 locales are available. Sample strings:
+/* parse browser locale header
+ *
+ * seems as most browsers just do a one after comma value even if more than 10 locales are available. Sample strings:
* opera:
* Accept-Language: sq;q=1.0,de;q=0.9,as;q=0.8,ar;q=0.7,bn;q=0.6,zh-cn;q=0.5,kn;q=0.4,ch;q=0.3,fo;q=0.2,gn;q=0.1,ce;q=0.1,ie;q=0.1
* Firefox
* 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
* Accept-Language: de,en-us;q=0.9,it;q=0.9,de-de;q=0.8,en-ph;q=0.7,de-at;q=0.7,zh-cn;q=0.6,cy;q=0.5,ar-om;q=0.5,en-tt;q=0.4,xh;q=0.3,nl-be;q=0.3,cs;q=0.2,sv;q=0.1,tk;q=0.1
* opera:
* Accept-Language: sq;q=1.0,de;q=0.9,as;q=0.8,ar;q=0.7,bn;q=0.6,zh-cn;q=0.5,kn;q=0.4,ch;q=0.3,fo;q=0.2,gn;q=0.1,ce;q=0.1,ie;q=0.1
* Firefox
* 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
* Accept-Language: de,en-us;q=0.9,it;q=0.9,de-de;q=0.8,en-ph;q=0.7,de-at;q=0.7,zh-cn;q=0.6,cy;q=0.5,ar-om;q=0.5,en-tt;q=0.4,xh;q=0.3,nl-be;q=0.3,cs;q=0.2,sv;q=0.1,tk;q=0.1
ls = &wanted_locales[i];
StrBufExtract_token(Buf, LocaleString, i, ',');
ls = &wanted_locales[i];
StrBufExtract_token(Buf, LocaleString, i, ',');
if (StrBufNum_tokens(Buf, '=') > 1) {
int sbuflen, k;
StrBufExtract_token(SBuf, Buf, 1, '=');
sbuflen = StrLength(SBuf);
if (StrBufNum_tokens(Buf, '=') > 1) {
int sbuflen, k;
StrBufExtract_token(SBuf, Buf, 1, '=');
sbuflen = StrLength(SBuf);
StrBufPeek(SBuf, NULL, k, '0');
StrBufPeek(SBuf, NULL, k, '0');
StrBufExtract_token(SBuf, Buf, 0, ';');
StrBufExtract_token(SBuf, Buf, 0, ';');
if (StrBufNum_tokens(SBuf, '-') > 1) {
extract_token(&ls->region[0],
ChrPtr(SBuf),
1, '-',
if (StrBufNum_tokens(SBuf, '-') > 1) {
extract_token(&ls->region[0],
ChrPtr(SBuf),
1, '-',
blen=strlen(&ls->lang[0]);
memcpy(&ls->region[0], ls->lang, blen);
ls->region[blen] = '\0';
}
blen=strlen(&ls->lang[0]);
memcpy(&ls->region[0], ls->lang, blen);
ls->region[blen] = '\0';
}
blen = strlen(&ls->region[0]);
for (j = 0; j < blen; j++)
{
int chars;
chars = toupper(ls->region[j]);
blen = strlen(&ls->region[0]);
for (j = 0; j < blen; j++)
{
int chars;
chars = toupper(ls->region[j]);
result = strcasecmp(&ls->lang[0], AvailLangLoaded[j]);
if ((result < 0) && (result < ls->availability)){
ls->availability = result;
ls->selectedlang = j;
}
result = strcasecmp(&ls->lang[0], AvailLangLoaded[j]);
if ((result < 0) && (result < ls->availability)){
ls->availability = result;
ls->selectedlang = j;
}
- if ((ls->availability <= 0) &&
- (av < ls->availability) &&
- (prio < ls->priority) &&
- (ls->selectedlang != -1)) {
+ if ( (ls->availability <= 0)
+ && (av < ls->availability)
+ && (prio < ls->priority)
+ && (ls->selectedlang != -1)
+ ) {
if (nLocalesLoaded == 1) {
wc_printf("<p>%s</p>", AvailLangLoaded[0]);
return;
}
if (nLocalesLoaded == 1) {
wc_printf("<p>%s</p>", AvailLangLoaded[0]);
return;
}
for (i = 0; i<nLocalesLoaded; ++i) {
if (!strcasecmp(lang, AvailLangLoaded[i])) {
WC->selected_language = i;
for (i = 0; i<nLocalesLoaded; ++i) {
if (!strcasecmp(lang, AvailLangLoaded[i])) {
WC->selected_language = i;
- uselocale(wc_locales[WCC->selected_language]); /** switch locales */
- textdomain(textdomain(NULL)); /** clear the cache */
+ uselocale(wc_locales[WCC->selected_language]); /* switch locales */
+ textdomain(textdomain(NULL)); /* clear the cache */
- uselocale(LC_GLOBAL_LOCALE); /** switch locales */
- textdomain(textdomain(NULL)); /** clear the cache */
+ uselocale(LC_GLOBAL_LOCALE); /* switch locales */
+ textdomain(textdomain(NULL)); /* clear the cache */
language = getenv("WEBCIT_LANG");
if ((language) && (!IsEmptyStr(language)) && (strcmp(language, "UNLIMITED") != 0)) {
language = getenv("WEBCIT_LANG");
if ((language) && (!IsEmptyStr(language)) && (strcmp(language, "UNLIMITED") != 0)) {
for (i = 0; i < nLocales; ++i) {
if ((language != NULL) && (strcmp(AvailLang[i], language) != 0))
continue;
for (i = 0; i < nLocales; ++i) {
if ((language != NULL) && (strcmp(AvailLang[i], language) != 0))
continue;
(((i > 0) && (wc_locales[0] != NULL)) ? wc_locales[0] : Empty_Locale)
);
if (wc_locales[nLocalesLoaded] == NULL) {
(((i > 0) && (wc_locales[0] != NULL)) ? wc_locales[0] : Empty_Locale)
);
if (wc_locales[nLocalesLoaded] == NULL) {
- lprintf(1, "locale for "LOCALEDIR"locale/%s: %s; disabled\n",
- buf,
- strerror(errno)
- );
+ syslog(LOG_NOTICE, "locale for %s disabled: %s", buf, strerror(errno));
- lprintf(1, "Your selected locale [%s] isn't available on your system. falling back to C\n", language);
+ syslog(LOG_WARNING, "Your selected locale [%s] isn't available on your system. falling back to C", language);
#ifdef HAVE_USELOCALE
wc_locales[0] = newlocale(
(LC_MESSAGES_MASK|LC_TIME_MASK),
AvailLang[0],
#ifdef HAVE_USELOCALE
wc_locales[0] = newlocale(
(LC_MESSAGES_MASK|LC_TIME_MASK),
AvailLang[0],
#else
setlocale(LC_MESSAGES, AvailLang[0]);
setenv("LANG", AvailLang[0], 1);
#else
setlocale(LC_MESSAGES, AvailLang[0]);
setenv("LANG", AvailLang[0], 1);
- 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"));
-
+ setlocale(LC_ALL, "");
+ syslog(LOG_DEBUG, "Text domain: %s", textdomain("webcit"));
+ syslog(LOG_DEBUG, "Text domain Charset: %s", bind_textdomain_codeset("webcit", "UTF8"));
+ syslog(LOG_DEBUG, "Message catalog directory: %s", bindtextdomain(textdomain(NULL), LOCALEDIR"/locale"));
void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
{
wc_printf("English (US)");
}
void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
{
wc_printf("English (US)");
}