#endif
}
-#ifdef HAVE_USELOCALE
- locale_t Empty_Locale;
-#endif
/*
* Create a locale_t for each available language
void initialize_locales(void) {
int nLocales;
int i;
- char buf[32];
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"));
+#endif
+
nLocales = 0;
while (!IsEmptyStr(AvailLang[nLocales]))
nLocales++;
#ifdef HAVE_USELOCALE
wc_locales = malloc (sizeof(locale_t) * nLocales);
memset(wc_locales,0, sizeof(locale_t) * nLocales);
- /* create default locale */
- Empty_Locale = newlocale(LC_ALL_MASK, NULL, NULL);
+ wc_locales[0] = newlocale(LC_ALL_MASK, NULL, NULL);
#endif
- 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]);
- }
+ for (i = 1; i < nLocales; ++i) {
#ifdef HAVE_USELOCALE
wc_locales[nLocalesLoaded] = newlocale(
(LC_MESSAGES_MASK|LC_TIME_MASK),
- buf,
- (((i > 0) && (wc_locales[0] != NULL)) ? wc_locales[0] : Empty_Locale)
+ AvailLang[i],
+ wc_locales[0]
);
if (wc_locales[nLocalesLoaded] == NULL) {
- syslog(1, "locale for %s disabled: %s", buf, strerror(errno));
+ syslog(1, "locale for %s disabled: %s (domain: %s, path: %s)",
+ AvailLang[i],
+ strerror(errno),
+ textdomain(NULL),
+ bindtextdomain(textdomain(NULL), NULL)
+ );
}
else {
- syslog(3, "Found locale: %s", buf);
+ syslog(3, "Found locale: %s", AvailLang[i]);
AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
nLocalesLoaded++;
}
#else
if ((language != NULL) && (strcmp(language, AvailLang[i]) == 0)) {
- setenv("LANG", buf, 1);
+ setenv("LANG", AvailLang[i], 1);
AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
setlocale(LC_MESSAGES, AvailLang[i]);
nLocalesLoaded++;
}
else if (nLocalesLoaded == 0) {
- setenv("LANG", buf, 1);
+ setenv("LANG", AvailLang[i], 1);
AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
nLocalesLoaded++;
}
}
if ((language != NULL) && (nLocalesLoaded == 0)) {
syslog(1, "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],
- Empty_Locale
- );
-#else
+#ifndef HAVE_USELOCALE
setlocale(LC_MESSAGES, AvailLang[0]);
setenv("LANG", AvailLang[0], 1);
#endif
AvailLangLoaded[0] = AvailLang[0];
nLocalesLoaded = 1;
}
-
-#ifdef ENABLE_NLS
- setlocale(LC_ALL, "");
- syslog(9, "Message catalog directory: %s", bindtextdomain("webcit", LOCALEDIR"/locale"));
- syslog(9, "Text domain: %s", textdomain("webcit"));
- syslog(9, "Text domain Charset: %s", bind_textdomain_codeset("webcit","UTF8"));
-#endif
}
#ifdef HAVE_USELOCALE
int i;
for (i = 0; i < nLocalesLoaded; ++i) {
- if (Empty_Locale != wc_locales[i]) {
- freelocale(wc_locales[i]);
- }
+ freelocale(wc_locales[i]);
}
free(wc_locales);
#endif
syslog(1, "Copyright (C) 1996-2012 by the citadel.org team");
syslog(1, " ");
syslog(1, "This program is open source software: you can redistribute it and/or");
- syslog(1, "modify it under the terms of the GNU General Public License as published");
- syslog(1, "by the Free Software Foundation, either version 3 of the License, or");
- syslog(1, "(at your option) any later version.");
+ syslog(1, "modify it under the terms of the GNU General Public License, version 3.");
syslog(1, " ");
syslog(1, "This program is distributed in the hope that it will be useful,");
syslog(1, "but WITHOUT ANY WARRANTY; without even the implied warranty of");
syslog(1, "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the");
syslog(1, "GNU General Public License for more details.");
syslog(1, " ");
- syslog(1, "You should have received a copy of the GNU General Public License");
- syslog(1, "along with this program. If not, see <http://www.gnu.org/licenses/>.");
- syslog(1, " ");
-
/* initialize various subsystems */