This patch adds code for LyX/Mac to find its locale files correctly
and changes the default user directory from .lyx to
~/Library/Preferences/LyX (for Qt/Mac too).

Lars, this changes some of your code in message.C. Is it OK with you?

JMarc

Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.1922
diff -u -p -r1.1922 ChangeLog
--- src/ChangeLog	1 Jun 2004 17:54:33 -0000	1.1922
+++ src/ChangeLog	2 Jun 2004 13:39:55 -0000
@@ -1,3 +1,13 @@
+2004-05-10  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* lyxrc.C: do not set user_email to a default value but use empty
+	instead. The entry used to be translated, which does not work
+	since at the point where lyxrc is constructed there is not
+	translation service available
+
+	* messages.C (getLocaleDir): remove and use directly
+	lyx_localedir() instead
+
 2004-06-01  Angus Leeming  <[EMAIL PROTECTED]>
 
 	* output_linuxdoc.C (linuxdocParagraphs): Check that the paragraph
Index: src/lyxrc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxrc.C,v
retrieving revision 1.173
diff -u -p -r1.173 lyxrc.C
--- src/lyxrc.C	20 Apr 2004 08:51:10 -0000	1.173
+++ src/lyxrc.C	2 Jun 2004 13:39:56 -0000
@@ -272,9 +272,6 @@ void LyXRC::setDefaults() {
 	user_name = lyx::support::user_name();
 
 	user_email = lyx::support::user_email();
-
-	if (user_email.empty())
-		user_email = _("email address unknown");
 }
 
 
Index: src/messages.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/messages.C,v
retrieving revision 1.15
diff -u -p -r1.15 messages.C
--- src/messages.C	6 Oct 2003 15:42:29 -0000	1.15
+++ src/messages.C	2 Jun 2004 13:39:56 -0000
@@ -21,21 +21,6 @@ using std::string;
 
 #ifdef ENABLE_NLS
 
-namespace {
-
-string const & getLocaleDir()
-{
-	static string locale_dir;
-
-	if (locale_dir.empty()) {
-		locale_dir = GetEnvPath("LYX_LOCALEDIR");
-		if (locale_dir.empty())
-			locale_dir = lyx_localedir();
-	}
-	return locale_dir;
-}
-
-} // anon namespace
 
 #if 0
 
@@ -55,7 +40,7 @@ public:
 		//lyxerr << "Messages: language(" << l
 		//       << ") in dir(" << dir << ")" << std::endl;
 
-		cat_gl = mssg_gl.open(PACKAGE, loc_gl, getLocaleDir().c_str());
+		cat_gl = mssg_gl.open(PACKAGE, loc_gl, lyx_localedir().c_str());
 
 	}
 
@@ -99,8 +84,6 @@ public:
 		//lyxerr << "Messages: language(" << l
 		//       << ") in dir(" << dir << ")" << std::endl;
 
-	      bindtextdomain(PACKAGE, getLocaleDir().c_str());
-	      textdomain(PACKAGE);
 	}
 
 	~Pimpl() {}
@@ -112,6 +95,8 @@ public:
 
 		char * old = strdup(setlocale(LC_ALL, 0));
 		char * n = setlocale(LC_ALL, lang_.c_str());
+		bindtextdomain(PACKAGE, lyx_localedir().c_str());
+		textdomain(PACKAGE);
 		const char* msg = gettext(m.c_str());
 		setlocale(LC_ALL, old);
 		free(old);
Index: src/support/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/ChangeLog,v
retrieving revision 1.254
diff -u -p -r1.254 ChangeLog
--- src/support/ChangeLog	27 May 2004 07:41:51 -0000	1.254
+++ src/support/ChangeLog	2 Jun 2004 13:39:56 -0000
@@ -1,3 +1,11 @@
+2004-05-04  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* path_defines.C.in (setLyxPaths): make sure that LyX/Mac can find
+	its po files when moved around; set default user directory to
+	~/Library/Preferences/LyX/ for LyX/Mac.
+	(lyx_localedir): return the value that may have been computed in
+	setLyXPaths 
+
 2004-05-27  Kayvan Sylvan <[EMAIL PROTECTED]>
 	
 	* Makefile.am (libsupport_la_SOURCES): remove reference to
Index: src/support/path_defines.C.in
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/path_defines.C.in,v
retrieving revision 1.11
diff -u -p -r1.11 path_defines.C.in
--- src/support/path_defines.C.in	27 Apr 2004 12:48:45 -0000	1.11
+++ src/support/path_defines.C.in	2 Jun 2004 13:39:56 -0000
@@ -40,6 +40,8 @@ string build_lyxdir_;
 // Store for the path to the user-level support files.
 string user_lyxdir_;
 
+// Store for the path to the locale directory.
+string localedir_;
 
 /* The absolute path to the system-level lyx support files.
  * (Make-time value.)
@@ -73,7 +75,10 @@ string const & top_srcdir()
 string const & lyx_localedir()
 {
 	static string const ll = "%LOCALEDIR%";
-	return ll;
+	if (localedir_.empty())
+		return ll;
+	else
+		return localedir_;
 }
 
 
@@ -287,6 +292,15 @@ bool setLyxPaths()
 		lyxerr[Debug::INIT] << "System directory: '"
 				    << system_lyxdir_ << '\'' << endl;
 
+	// This is true when we are running from a Mac OS X bundle
+	// (for LyX/Mac)
+	bool const inOSXBundle = 
+		system_lyxdir_ == NormalizePath(AddPath(binpath, "../Resources/")
+						+ OnlyFilename(binname));
+	if (inOSXBundle)
+		lyxerr[Debug::INIT] << "Running from LyX/Mac bundle."
+				    << endl;
+
 	//
 	// Set PATH for LyX/Mac
 	// LyX/Mac is a relocatable application bundle; here we add to
@@ -295,14 +309,32 @@ bool setLyxPaths()
 	// needs to run latex, previewers, etc.
 	//
 
-	if (system_lyxdir_ == NormalizePath(AddPath(binpath, "../Resources/")
-					    + OnlyFilename(binname))) {
-	  const string newpath = GetEnv("PATH") + ":" + binpath
-	    + ":/sw/bin:/usr/local/bin"
-	    + ":/usr/local/teTeX/bin/powerpc-apple-darwin-current";
-	  lyx::support::putenv("PATH", newpath);
-	  lyxerr[Debug::INIT] << "Running from LyX/Mac bundle. "
-	    "Setting PATH to: " << GetEnv("PATH") << endl;
+	if (inOSXBundle) {
+		const string newpath = GetEnv("PATH") + ":" + binpath
+			+ ":/sw/bin:/usr/local/bin"
+			+ ":/usr/local/teTeX/bin/powerpc-apple-darwin-current";
+		lyx::support::putenv("PATH", newpath);
+		lyxerr[Debug::INIT] << "LyX/Mac: setting PATH to: " 
+				    << GetEnv("PATH") << endl;
+	}
+
+
+	// 
+	// Determine locale directory
+	//
+	if (!GetEnv("LYX_LOCALEDIR").empty()) {
+		localedir_ = GetEnv("LYX_LOCALEDIR");
+		lyxerr[Debug::INIT] << "LYX_LOCALEDIR=" << localedir_ << endl;
+	} else if (inOSXBundle) {
+		string const maybe_localedir = 
+			NormalizePath(AddPath(system_lyxdir_, "../locale")); 
+		FileInfo fi(maybe_localedir);
+		if (fi.isOK() && fi.isDir()) {
+			lyxerr[Debug::INIT] 
+				<< "LyX/Mac: setting locale directory to "
+				<< maybe_localedir << endl;
+			localedir_ = maybe_localedir;
+		}
 	}
 
 	//
@@ -323,9 +355,13 @@ bool setLyxPaths()
 
 		// default behaviour
 		if (user_lyxdir_.empty())
-			user_lyxdir_ = AddPath(GetEnvPath("HOME"),
-					       string(".") + PACKAGE);
-			explicit_userdir = false;
+			if (inOSXBundle)
+				user_lyxdir_ = AddPath(GetEnvPath("HOME"),
+						       "Library/Preferences/LyX");
+			else
+				user_lyxdir_ = AddPath(GetEnvPath("HOME"),
+						       string(".") + PACKAGE);
+		explicit_userdir = false;
 	}
 
 	lyxerr[Debug::INIT] << "User LyX directory: '"

Reply via email to