From: Art Cancro Date: Thu, 16 Feb 2006 03:45:05 +0000 (+0000) Subject: Localization hacks. X-Git-Tag: v7.86~4198 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=e32b4883e5a48241c400138cf95532472fb38463;hp=293033e226b842c7353a5bf852285a34331f39af;p=citadel.git Localization hacks. wc_strftime() now falls back to strftime() instead of strftime_l() if the selected locale is NULL. This causes the time to be output in the 'C' locale, but at least it doesn't crash. Locales are now initialized slightly differently. The 'C' locale is now initialized without the '.UTF8' suffix. And if it is successfully initialized, all of the other locales are initialized using it as a base. --- diff --git a/webcit/fmt_date.c b/webcit/fmt_date.c index a8c16b12a..2c7c9f6fd 100644 --- a/webcit/fmt_date.c +++ b/webcit/fmt_date.c @@ -26,7 +26,12 @@ typedef unsigned char byte; /**< a byte. */ size_t wc_strftime(char *s, size_t max, const char *format, const struct tm *tm) { #ifdef ENABLE_NLS - return strftime_l(s, max, format, tm, wc_locales[WC->selected_language]); + if (wc_locales[WC->selected_language] == NULL) { + return strftime(s, max, format, tm); + } + else { + return strftime_l(s, max, format, tm, wc_locales[WC->selected_language]); + } #else return strftime(s, max, format, tm); #endif diff --git a/webcit/gettext.c b/webcit/gettext.c index c83c41ee0..ddee2f873 100644 --- a/webcit/gettext.c +++ b/webcit/gettext.c @@ -251,11 +251,16 @@ void initialize_locales(void) { Empty_Locale = newlocale(LC_ALL_MASK, NULL, NULL); for (i = 0; i < NUM_LANGS; ++i) { - sprintf(buf, "%s.UTF8", AvailLang[i]); + if (i == 0) { + sprintf(buf, "%s", AvailLang[i]); // locale 0 (C) is ascii, not utf-8 + } + else { + sprintf(buf, "%s.UTF8", AvailLang[i]); + } wc_locales[i] = newlocale( (LC_MESSAGES_MASK|LC_TIME_MASK), buf, - Empty_Locale + (((i > 0) && (wc_locales[0] != NULL)) ? wc_locales[0] : Empty_Locale) ); if (wc_locales[i] == NULL) { lprintf(1, "Error configuring locale for %s: %s\n",