The following patch changes the logic that is used to find the
localized documentation. In many cases with the old code, it was
possible to have french menus with english docs, for example. 

I am going to apply that now, but I'd appreciate if people could check
that it gets the locale right in their setting.

JMarc

Index: src/support/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/ChangeLog,v
retrieving revision 1.149.2.5
diff -u -p -r1.149.2.5 ChangeLog
--- src/support/ChangeLog	9 Apr 2003 17:14:01 -0000	1.149.2.5
+++ src/support/ChangeLog	23 Mar 2004 14:37:39 -0000
@@ -1,3 +1,8 @@
+2004-03-23  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* filetools.C (i18nLibFileSearch): fix the logic to match closely
+	what gettext does
+
 2003-04-09  John Levon  <[EMAIL PROTECTED]>
 
 	* filetools.C: fix MakeDisplayPath() to not lie
Index: src/support/filetools.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.C,v
retrieving revision 1.146.2.1
diff -u -p -r1.146.2.1 filetools.C
--- src/support/filetools.C	9 Apr 2003 17:14:01 -0000	1.146.2.1
+++ src/support/filetools.C	23 Mar 2004 14:37:39 -0000
@@ -307,20 +307,32 @@ string const
 i18nLibFileSearch(string const & dir, string const & name,
 		  string const & ext)
 {
-	// this comment is from intl/dcigettext.c. We try to mimick this
-	// behaviour here.
+	// the following comments are from intl/dcigettext.c. We try
+	// to mimick this behaviour here.
 	/* The highest priority value is the `LANGUAGE' environment
 	   variable. But we don't use the value if the currently
 	   selected locale is the C locale. This is a GNU extension. */
+	/* [Otherwise] We have to proceed with the POSIX methods of
+	   looking to `LC_ALL', `LC_xxx', and `LANG'. On some systems
+	   this can be done by the `setlocale' function itself.  */
 
-	string const lc_all = GetEnv("LC_ALL");
-	string lang = GetEnv("LANGUAGE");
-	if (lang.empty() || lc_all == "C") {
-		lang = lc_all;
+#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
+	lang = setlocale(LC_MESSAGES, NULL);
+#else
+	string lang = GetEnv("LC_ALL");
+	if (lang.empty()) {
+		lang = GetEnv("LC_MESSAGES");
 		if (lang.empty()) {
 			lang = GetEnv("LANG");
+			if (lang.empty())
+				lang = "C";
 		}
 	}
+#endif
+
+	string const language = GetEnv("LANGUAGE");
+	if (lang != "C" && !language.empty())
+		lang = language;
 
 	lang = token(lang, '_', 0);
 

Reply via email to