projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4582e28
)
Revert "removed empty_locale and just use wc_locales[0] for this purpose"
author
Art Cancro
<ajc@uncensored.citadel.org>
Sun, 26 Feb 2012 20:15:53 +0000
(15:15 -0500)
committer
Art Cancro
<ajc@uncensored.citadel.org>
Sun, 26 Feb 2012 20:15:53 +0000
(15:15 -0500)
This reverts commit
cb12b5d312998b1d481d80ddd65c9aa7e0cf425e
.
webcit/gettext.c
patch
|
blob
|
history
diff --git
a/webcit/gettext.c
b/webcit/gettext.c
index 25474e810c5b8f68eb2f521cdc90de0be6dbb3ad..58a0edd8d78bb48437893ecab62f4a47ccf37ab4 100644
(file)
--- a/
webcit/gettext.c
+++ b/
webcit/gettext.c
@@
-280,6
+280,9
@@
void stop_selected_language(void) {
#endif
}
#endif
}
+#ifdef HAVE_USELOCALE
+ locale_t Empty_Locale;
+#endif
/*
* Create a locale_t for each available language
/*
* Create a locale_t for each available language
@@
-287,6
+290,7
@@
void stop_selected_language(void) {
void initialize_locales(void) {
int nLocales;
int i;
void initialize_locales(void) {
int nLocales;
int i;
+ char buf[32];
char *language = NULL;
#ifdef ENABLE_NLS
char *language = NULL;
#ifdef ENABLE_NLS
@@
-311,38
+315,47
@@
void initialize_locales(void) {
#ifdef HAVE_USELOCALE
wc_locales = malloc (sizeof(locale_t) * nLocales);
memset(wc_locales,0, sizeof(locale_t) * 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);
+ /* create default locale */
+ Empty_Locale = newlocale(LC_ALL_MASK, NULL, NULL);
#endif
#endif
- for (i = 1; i < nLocales; ++i) {
+ for (i = 0; i < nLocales; ++i) {
+ if ((language != NULL) && (strcmp(AvailLang[i], language) != 0))
+ continue;
+ if (i == 0) {
+ sprintf(buf, "%s", AvailLang[i]); /* locale 0 (C) is ascii, not utf-8 */
+ }
+ else {
+ sprintf(buf, "%s.UTF8", AvailLang[i]);
+ }
#ifdef HAVE_USELOCALE
wc_locales[nLocalesLoaded] = newlocale(
(LC_MESSAGES_MASK|LC_TIME_MASK),
#ifdef HAVE_USELOCALE
wc_locales[nLocalesLoaded] = newlocale(
(LC_MESSAGES_MASK|LC_TIME_MASK),
-
AvailLang[i]
,
- wc_locales[0]
+
buf
,
+ Empty_Locale
);
if (wc_locales[nLocalesLoaded] == NULL) {
syslog(1, "locale for %s disabled: %s (domain: %s, path: %s)",
);
if (wc_locales[nLocalesLoaded] == NULL) {
syslog(1, "locale for %s disabled: %s (domain: %s, path: %s)",
-
AvailLang[i]
,
+
buf
,
strerror(errno),
textdomain(NULL),
bindtextdomain(textdomain(NULL), NULL)
);
}
else {
strerror(errno),
textdomain(NULL),
bindtextdomain(textdomain(NULL), NULL)
);
}
else {
- syslog(3, "Found locale: %s",
AvailLang[i]
);
+ syslog(3, "Found locale: %s",
buf
);
AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
nLocalesLoaded++;
}
#else
if ((language != NULL) && (strcmp(language, AvailLang[i]) == 0)) {
AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
nLocalesLoaded++;
}
#else
if ((language != NULL) && (strcmp(language, AvailLang[i]) == 0)) {
- setenv("LANG",
AvailLang[i]
, 1);
+ setenv("LANG",
buf
, 1);
AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
setlocale(LC_MESSAGES, AvailLang[i]);
nLocalesLoaded++;
}
else if (nLocalesLoaded == 0) {
AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
setlocale(LC_MESSAGES, AvailLang[i]);
nLocalesLoaded++;
}
else if (nLocalesLoaded == 0) {
- setenv("LANG",
AvailLang[i]
, 1);
+ setenv("LANG",
buf
, 1);
AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
nLocalesLoaded++;
}
AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
nLocalesLoaded++;
}
@@
-350,7
+363,13
@@
void initialize_locales(void) {
}
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
+#ifdef HAVE_USELOCALE
+ wc_locales[0] = newlocale(
+ (LC_MESSAGES_MASK|LC_TIME_MASK),
+ AvailLang[0],
+ Empty_Locale
+ );
+#else
setlocale(LC_MESSAGES, AvailLang[0]);
setenv("LANG", AvailLang[0], 1);
#endif
setlocale(LC_MESSAGES, AvailLang[0]);
setenv("LANG", AvailLang[0], 1);
#endif
@@
-367,7
+386,9
@@
ServerShutdownModule_GETTEXT
#ifdef HAVE_USELOCALE
int i;
for (i = 0; i < nLocalesLoaded; ++i) {
#ifdef HAVE_USELOCALE
int i;
for (i = 0; i < nLocalesLoaded; ++i) {
- freelocale(wc_locales[i]);
+ if (Empty_Locale != wc_locales[i]) {
+ freelocale(wc_locales[i]);
+ }
}
free(wc_locales);
#endif
}
free(wc_locales);
#endif