]> code.citadel.org Git - citadel.git/blobdiff - webcit/gettext.c
GETTEXT: represent C as en_US to the user - no one speaks C that fluently after all ;-)
[citadel.git] / webcit / gettext.c
index 5e5d0909bb2e1bc55d37e4b71e656adbd8b7c2a4..acb0331ce74ae6bbe19eb5fc9a8b38f306a4ad5d 100644 (file)
@@ -17,7 +17,8 @@
 #ifdef ENABLE_NLS
 /* actual supported locales */
 const char *AvailLang[] = {
-       "C",
+       "en_US",
+       "ar_AE",
        "bg_BG",
        "cs_CZ",
        "en_US",
@@ -196,7 +197,7 @@ void httplang_to_locale(StrBuf *LocaleString, wcsession *sess)
                nBest=0;
        }
        sess->selected_language = nBest;
-       syslog(9, "language found: %s", AvailLangLoaded[WC->selected_language]);
+       syslog(LOG_DEBUG, "language found: %s", AvailLangLoaded[WC->selected_language]);
        FreeStrBuf(&Buf);
        FreeStrBuf(&SBuf);
 }
@@ -299,7 +300,7 @@ void initialize_locales(void) {
 
        language = getenv("WEBCIT_LANG");
        if ((language) && (!IsEmptyStr(language)) && (strcmp(language, "UNLIMITED") != 0)) {
-               syslog(9, "Nailing locale to %s", language);
+               syslog(LOG_INFO, "Nailing locale to %s", language);
        }
        else language = NULL;
 
@@ -316,7 +317,8 @@ void initialize_locales(void) {
                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 */
+                       sprintf(buf, "C");      /* locale 0 (C) is ascii, not utf-8 */
+                       
                }
                else {
                        sprintf(buf, "%s.UTF8", AvailLang[i]);
@@ -328,10 +330,10 @@ void initialize_locales(void) {
                        (((i > 0) && (wc_locales[0] != NULL)) ? wc_locales[0] : Empty_Locale)
                );
                if (wc_locales[nLocalesLoaded] == NULL) {
-                       syslog(1, "locale for %s disabled: %s", buf, strerror(errno));
+                       syslog(LOG_NOTICE, "locale for %s disabled: %s", buf, strerror(errno));
                }
                else {
-                       syslog(3, "Found locale: %s", buf);
+                       syslog(LOG_INFO, "Found locale: %s - %s", buf, AvailLang[i]);
                        AvailLangLoaded[nLocalesLoaded] = AvailLang[i];
                        nLocalesLoaded++;
                }
@@ -350,7 +352,7 @@ void initialize_locales(void) {
 #endif
        }
        if ((language != NULL) && (nLocalesLoaded == 0)) {
-               syslog(1, "Your selected locale [%s] isn't available on your system. falling back to C", language);
+               syslog(LOG_WARNING, "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),
@@ -367,9 +369,9 @@ void initialize_locales(void) {
 
 #ifdef ENABLE_NLS
        setlocale(LC_ALL, "");
-       syslog(9, "Text domain: %s", textdomain("webcit"));
-       syslog(9, "Text domain Charset: %s", bind_textdomain_codeset("webcit", "UTF8"));
-       syslog(9, "Message catalog directory: %s", bindtextdomain(textdomain(NULL), LOCALEDIR"/locale"));
+       syslog(LOG_DEBUG, "Text domain: %s", textdomain("webcit"));
+       syslog(LOG_DEBUG, "Text domain Charset: %s", bind_textdomain_codeset("webcit", "UTF8"));
+       syslog(LOG_DEBUG, "Message catalog directory: %s", bindtextdomain(textdomain(NULL), LOCALEDIR"/locale"));
 #endif
 }
 
@@ -426,10 +428,11 @@ void initialize_locales(void) {
 
 #endif /* ENABLE_NLS */
 
-
 void TmplGettext(StrBuf *Target, WCTemplputParams *TP)
 {
-       StrBufAppendBufPlain(Target, _(TP->Tokens->Params[0]->Start), -1, 0);
+       const char *Text = _(TP->Tokens->Params[0]->Start);
+
+       StrBufAppendTemplateStr(Target, TP, Text, 1);
 }
 
 
@@ -440,7 +443,7 @@ void TmplGettext(StrBuf *Target, WCTemplputParams *TP)
 const char *get_selected_language(void) {
 #ifdef ENABLE_NLS
 #ifdef HAVE_USELOCALE
-       return AvailLang[WC->selected_language];
+       return AvailLangLoaded[WC->selected_language];
 #else
        return "en";
 #endif