From e32b4883e5a48241c400138cf95532472fb38463 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 16 Feb 2006 03:45:05 +0000 Subject: [PATCH] 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. --- webcit/fmt_date.c | 7 ++++++- webcit/gettext.c | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) 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", -- 2.30.2