Localization hacks.
authorArt Cancro <ajc@citadel.org>
Thu, 16 Feb 2006 03:45:05 +0000 (03:45 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 16 Feb 2006 03:45:05 +0000 (03:45 +0000)
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
webcit/gettext.c

index a8c16b12a5136dcd64ca8f32433730b7e1cb6b17..2c7c9f6fd237b82981375bf8b9d8a50d7dc235d0 100644 (file)
@@ -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
index c83c41ee07f5fc81b9b5ec563686cdb6e7968acf..ddee2f87377085f8c95eccb7747aff54216dc442 100644 (file)
@@ -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",