projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e56f606
)
* remove locales from the login window if webcit isn't able to load it.
author
Wilfried Göesgens
<willi@citadel.org>
Tue, 5 Aug 2008 19:22:10 +0000
(19:22 +0000)
committer
Wilfried Göesgens
<willi@citadel.org>
Tue, 5 Aug 2008 19:22:10 +0000
(19:22 +0000)
webcit/gettext.c
patch
|
blob
|
history
diff --git
a/webcit/gettext.c
b/webcit/gettext.c
index 52332f8152b64a4db519d1e8403c808749969745..549dfa0d89742d4444ef3b0365f8d6f2c57323db 100644
(file)
--- a/
webcit/gettext.c
+++ b/
webcit/gettext.c
@@
-11,7
+11,7
@@
#define SEARCH_LANG 20 /* how many langs should we parse? */
/* actual supported locales */
#define SEARCH_LANG 20 /* how many langs should we parse? */
/* actual supported locales */
-char *AvailLang[NUM_LANGS] = {
+c
onst c
har *AvailLang[NUM_LANGS] = {
"C",
"en_US",
"de_DE",
"C",
"en_US",
"de_DE",
@@
-24,6
+24,9
@@
char *AvailLang[NUM_LANGS] = {
"pt_BR"
};
"pt_BR"
};
+const char *AvailLangLoaded[NUM_LANGS];
+long nLocalesLoaded = 0;
+
#ifdef HAVE_USELOCALE
locale_t wc_locales[NUM_LANGS]; /**< here we keep the parsed stuff */
#endif
#ifdef HAVE_USELOCALE
locale_t wc_locales[NUM_LANGS]; /**< here we keep the parsed stuff */
#endif
@@
-109,19
+112,19
@@
void httplang_to_locale(char *LocaleString)
/** check if we have this lang */
ls->availability=1;
ls->selectedlang=-1;
/** check if we have this lang */
ls->availability=1;
ls->selectedlang=-1;
- for (j=0; j<
NUM_LANGS
; j++) {
+ for (j=0; j<
nLocalesLoaded
; j++) {
int result;
/** match against the LANG part */
int result;
/** match against the LANG part */
- result=strcasecmp(&ls->lang[0], AvailLang[j]);
+ result=strcasecmp(&ls->lang[0], AvailLang
Loaded
[j]);
if ((result<0)&&(result<ls->availability)){
ls->availability=result;
ls->selectedlang=j;
}
/** match against lang and locale */
if ((result<0)&&(result<ls->availability)){
ls->availability=result;
ls->selectedlang=j;
}
/** match against lang and locale */
- if (0==strcasecmp(&lbuf[0], AvailLang[j])){
+ if (0==strcasecmp(&lbuf[0], AvailLang
Loaded
[j])){
ls->availability=0;
ls->selectedlang=j;
ls->availability=0;
ls->selectedlang=j;
- j=
NUM_LANGS
;
+ j=
nLocalesLoaded
;
}
}
}
}
}
}
@@
-145,7
+148,7
@@
void httplang_to_locale(char *LocaleString)
nBest=0;
}
WC->selected_language=nBest;
nBest=0;
}
WC->selected_language=nBest;
- lprintf(9, "language found: %s\n", AvailLang[WC->selected_language]);
+ lprintf(9, "language found: %s\n", AvailLang
Loaded
[WC->selected_language]);
}
/* TODO: we skip the language weighting so far. */
}
/* TODO: we skip the language weighting so far. */
@@
-202,14
+205,14
@@
void offer_languages(void) {
wprintf("<select name=\"language\" id=\"lname\" size=\"1\">\n");
wprintf("<select name=\"language\" id=\"lname\" size=\"1\">\n");
- for (i=0; i <
NUM_LANGS
; ++i) {
+ for (i=0; i <
nLocalesLoaded
; ++i) {
#ifndef HAVE_USELOCALE
#ifndef HAVE_USELOCALE
- if (strcmp(AvailLang[i], Lang) == 0)
+ if (strcmp(AvailLang
Loaded
[i], Lang) == 0)
#endif
wprintf("<option %s value=%s>%s</option>\n",
((WC->selected_language == i) ? "selected" : ""),
#endif
wprintf("<option %s value=%s>%s</option>\n",
((WC->selected_language == i) ? "selected" : ""),
- AvailLang[i],
- AvailLang[i]
+ AvailLang
Loaded
[i],
+ AvailLang
Loaded
[i]
);
}
);
}
@@
-224,8
+227,8
@@
void set_selected_language(const char *lang) {
int i;
#ifdef HAVE_USELOCALE
int i;
#ifdef HAVE_USELOCALE
- for (i=0; i<
NUM_LANGS
; ++i) {
- if (!strcasecmp(lang, AvailLang[i])) {
+ for (i=0; i<
nLocalesLoaded
; ++i) {
+ if (!strcasecmp(lang, AvailLang
Loaded
[i])) {
WC->selected_language = i;
}
}
WC->selected_language = i;
}
}
@@
-237,8
+240,9
@@
void set_selected_language(const char *lang) {
*/
void go_selected_language(void) {
#ifdef HAVE_USELOCALE
*/
void go_selected_language(void) {
#ifdef HAVE_USELOCALE
- if (WC->selected_language < 0) return;
- uselocale(wc_locales[WC->selected_language]); /** switch locales */
+ struct 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;
textdomain(textdomain(NULL)); /** clear the cache */
#else
char *language;
@@
-295,12
+299,12
@@
void initialize_locales(void) {
sprintf(buf, "%s.UTF8", AvailLang[i]);
}
#ifdef HAVE_USELOCALE
sprintf(buf, "%s.UTF8", AvailLang[i]);
}
#ifdef HAVE_USELOCALE
- wc_locales[
i
] = newlocale(
+ wc_locales[
nLocalesLoaded
] = newlocale(
(LC_MESSAGES_MASK|LC_TIME_MASK),
buf,
(((i > 0) && (wc_locales[0] != NULL)) ? wc_locales[0] : Empty_Locale)
);
(LC_MESSAGES_MASK|LC_TIME_MASK),
buf,
(((i > 0) && (wc_locales[0] != NULL)) ? wc_locales[0] : Empty_Locale)
);
- if (wc_locales[
i
] == NULL) {
+ if (wc_locales[
nLocalesLoaded
] == NULL) {
lprintf(1, "Error configuring locale for %s: %s\n",
buf,
strerror(errno)
lprintf(1, "Error configuring locale for %s: %s\n",
buf,
strerror(errno)
@@
-308,6
+312,8
@@
void initialize_locales(void) {
}
else {
lprintf(3, "Configured available locale: %s\n", buf);
}
else {
lprintf(3, "Configured available locale: %s\n", buf);
+ AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
+ nLocalesLoaded++;
}
#endif
}
}
#endif
}
@@
-317,7
+323,7
@@
void ShutdownLocale(void)
{
int i;
#ifdef HAVE_USELOCALE
{
int i;
#ifdef HAVE_USELOCALE
- for (i = 0; i <
NUM_LANGS
; ++i) {
+ for (i = 0; i <
nLocalesLoaded
; ++i) {
if (Empty_Locale != wc_locales[i])
freelocale(wc_locales[i]);
}
if (Empty_Locale != wc_locales[i])
freelocale(wc_locales[i]);
}