lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Lynx-dev] Proposed patch to init preferred-doc-lang from LANG/LAN


From: Chuck Houpt
Subject: Re: [Lynx-dev] Proposed patch to init preferred-doc-lang from LANG/LANGUAGE
Date: Mon, 23 Apr 2007 10:58:44 -0400

Thanks for the feedback.

€ you don't use the LANG environment variable, you use LC_MESSAGES via
  setlocale(3) if --enable-nls was given at configure time; setlocale(3)'s
  job is to check LANG, LC_MESSAGES and LC_ALL
€ There is no LANGUAGE environment variable©–. Period.


You're right. The patch should use setlocale(), rather than directly accessing LANG. The LANGUAGE environment variable is a GNU gettext extension, so it should only be used in conjunction with GNU gettext's libintl.

Below is an improved version of the code patch.

Thanks - Chuck


diff -ru lynx2-8-7/src/LYMain.c lynx2-8-7-patch/src/LYMain.c
--- lynx2-8-7/src/LYMain.c      2006-11-12 20:29:33.000000000 -0500
+++ lynx2-8-7-patch/src/LYMain.c        2007-04-23 10:18:27.000000000 -0400
@@ -1126,7 +1126,25 @@
     StrAllocCopy(personal_type_map, PERSONAL_MAILCAP);
     StrAllocCopy(global_extension_map, GLOBAL_EXTENSION_MAP);
     StrAllocCopy(personal_extension_map, PERSONAL_EXTENSION_MAP);
-    StrAllocCopy(language, PREFERRED_LANGUAGE);
+
+#ifdef LOCALE
+#ifdef HAVE_LIBINTL_H
+    if ((cp = LYGetEnv("LANGUAGE")) != NULL) {
+        StrAllocCopy(language, cp);
+        cp = language;
+        while ((cp = strpbrk(cp, ":"))) *cp = ',';
+    } else
+#endif /* HAVE_LIBINTL_H */
+    if ((cp = setlocale(LC_MESSAGES, NULL)) != NULL
+         && !strcmp(cp, "") && !strcmp(cp, "C") && !strcmp(cp, "POSIX")) {
+        StrAllocCopy(language, cp);
+        if ((cp = strpbrk(language, "."))) *cp = '\0';
+    } else
+#endif /* LOCALE */
+    {
+        StrAllocCopy(language, PREFERRED_LANGUAGE);
+    }
+
     StrAllocCopy(pref_charset, PREFERRED_CHARSET);
     StrAllocCopy(system_mail, SYSTEM_MAIL);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]